Saw the title and thought you meant Blue Magic. Kind of relieved that it's not, frankly, as that's a big bag of worms (to be dealt with later or possibly never ).
Maybe each spell/ability has a 'percentage known' variable that ranges from 0-100. Actually... it should probably be attached to the character, right? ...Either way, it'd require an variable for each individual spell, or at least some kind of array to track buildup independently.
Anyway, this 'SpellKnown' variable could be modified by battle condition:
If (Esper == Maduin) && (BattleVictory){
CureKnown = Max[CureKnown + (AbilityPoints x 3), 100]
Cure2Known = Max[Cure2Known + AbiltyPoints, 100]
}
If (CureKnown == 100){
Disp "Learned Cure!"
}
If (Cure2Known == 100){
Disp "Learned Cure 2!"
}
by item or shop:
If (LearnCure){
CureKnown = 100
}
or even by game event:
If (FightingGolbez){
MeteoKnown = 100
}
If it's a variable that can be referenced in multiple places, then creators could do really cool things like make the spell available before it's learned completely (but at an elevated cost or decreased power based on the percentage known), teach Blue Spells instantly during battle given the correct conditions, or even teach spells from chests (FF1 and FF5 both do this).
I don't know how viable tracking them individually like that would work, but if I were attempting this sort of thing (which I wouldn't, because I can't code to save my life) I'd try to do it like that.