Oh, okay you missed the Part about the Types 
if %spellbook in %Mage_Book
%SpellBook is the ID for the Book, not the Type which is what we are comparing when we look. 
And Delete these lines. Trying to explain that they are already set when you use the gosub.  
  set %1 %ScrollSecure
  set %2 %spellbook
  set %3 %scroll . %N
You can see it with this little snippet of code
Gosub Test This is a test
Halt 
Sub Test
Display %1 %2 %3 %4 
Return
When you use a gosub, it automatically sets %1 %2 %3 %4 %5 etc etc etc