scripting challenge: Large/Smaller text size
Malte Brill
revolution at derbrill.de
Sun Jul 3 07:06:40 EDT 2005
Update on my script. Turned it into a setprop handler. Put wouter´s
suggestions in. Thanks Wouter!
Usage:
set the changeSize of fld "myField" to 1
set the changeSize of fld "myField" to -1
Script (in card or stack)
setProp changeSize myChange
if myChange is not a number then
return "Error: parameter must be a number!"
exit changeSize
end if
if there is no field the target then
return "Error: Target must be a field!"&&the target
exit changeSize
end if
put the htmlText of the target into theHtml
if the effective textSize of the target+myChange<8 then
return "Smallest size reached"
exit changeSize
end if
set the textSize of the target to \
the effective textSize of the target+myChange
replace "size=""e with "size="&numToChar(1500) in theHTML
set the itemdel to numToChar(1500)
if the number of items of theHTML<>1 then
put 0 into testItem
repeat for each item theItem in theHTML
add 1 to testItem
if testItem<>1 then
put offset(quote,theitem) into counter
put char 1 to counter-1 of theItem into theSize
put theSize+myChange into theSize
if theSize<8 then
set the textSize of the target to \
the effective textSize of the target-myChange
return "Smallest size reached!"
exit changeSize
end if
put theSize into char 1 to counter-1 of theItem
put quote&theItem after newHTML
else
put theItem into newHTML
next repeat
end if
end repeat
set the htmlText of the target to newHTML
end if
put the htmlText of the target
end ChangeSize
Cheers,
Malte
More information about the use-livecode
mailing list