|
|
PrintF in Lingo
Added on 6/30/1999
|
Anyone want a rudimentary printF function in Lingo? If you don"t then please delete this message. If you do, then this is the limit of the function. It only pads spaces after the last character, not before or after the decimal point. How do you call it? You call it like this: PrintF [[a,b], [c,d],...] or printF [[a,b]]. Ex: PrintF [[x,20],["-",1],[y,20]]. This will reserve 20 characters for x, add a seperating "-" sign and then reserve 20 characters for y. You have an virtually unlimited number of arguments you can pass in one PrintF.
on FN
-- function range tester
-- by Alex Zavatone 8/2/95
-- Macromedia
set the floatprecision = 20
set mylist = ["Sin(x)",2, 10, .1]
set thestart = getat(myList, 2)
set theEnd = getat(myList, 3)
set theStep = getat(myList, 4)
set theFn = getat(myList, 1)
set theLoop = theStart
put "Evaluating "& string(theFn)& " from "&theStart&" to "&theEnd&", step "&theStep
repeat while theLoop <= theEnd + theStep
set x = theLoop
PrintF [[x, 20], [" -> ",4],[ value(theFN), 22]]
set theLoop = theLoop + theStep
end repeat
end
on PrintF argumentList, returnField
-- printF by Alex Zavatone 8/2/1995
-- Macromedia
set output = Empty
repeat with currentArg =1 to count (argumentlist)
set DesiredLength = getat(getat(argumentList,currentarg ), 2)
set realLength = the number of chars in(string(getat(getat(argumentList,currentarg ), 1)))
put getat(getat(argumentList,currentarg ), 1) after output
-- here we fill in the spaces after the statements have been output
set output = (FillInTheSpaces(realLength, DesiredLength, output))
end repeat
put output
end
on FillInTheSpaces realLength, DesiredLength, output
repeat with temp = realLength to DesiredLength
put " " after Output
end repeat
return output
end
|
|