"do" statements and value function
Francis Nugent Dixon
effendi at wanadoo.fr
Tue Jun 21 06:57:50 EDT 2011
Hi from Beautiful Brittany,
I agree with Tim.
Firstly, I use "Do" functions every day, and run
up "Do" statements of many lines (building it up
in a variable). effectively making mistakes in
the generation until I get it right !
Couldn't do without the "Do" statement, but I guess
that many LiveCoders don't find a use for it.
I used to use it much more in Hypercard.
As a simple example (watch out for wraps) :
--
-- Build AppleScript to call Skim, in my variable
"LVMasterScript"
--
put LVDataPath & field "MyFileName" into LVFilePath -- Build
Full File Path from Partial and File Name.
put "set LVFilePath to POSIX file " & quote & LVDataPath & field
"MyFileName" & quote into line 1 of LVMasterScript
put "tell application " & quote & "Skim" & quote into line 2 of
LVMasterScript
put "set myDocument to open LVFilePath" into line 3 of
LVMasterScript
put "tell myDocument" into line 4 of LVMasterScript
put char 1 to 3 of field "MyPages" into LVPage -- Pick up Page
Number.
if field MyScaleFactor is empty then put "2.0" into field
MyScaleFactor -- Take default scale value.
put field MyScaleFactor into LVScaleFactor
put "set view settings to {scale factor:" & LVScaleFactor & ",
auto scales:false}" into line 5 of LVMasterScript
put "go to page " & LVPage into line 6 of LVMasterScript
put "end tell" into line 7 of LVMasterScript
put "activate" into line 8 of LVMasterScript
put "end tell" into line 9 of LVMasterScript
do LVMasterScript as AppleScript
- Francis
"Nothing should ever be done for the first time !"
More information about the use-livecode
mailing list