| 1 | -- doCommandMovieScript |
|---|
| 2 | ----------------------------------- |
|---|
| 3 | -- DESCRIPTION: |
|---|
| 4 | -- process the command, which was chosen |
|---|
| 5 | -- at this point the command string is stored in the globallist, |
|---|
| 6 | -- as we come here in an asynch process -> MUI dialog |
|---|
| 7 | -- the command and the paramaters are stored in the global list which we get with: |
|---|
| 8 | -- call(#mGetGlobalList, mGetXScript()) |
|---|
| 9 | -- the command string is glob.getaprop(#cmd) |
|---|
| 10 | -- the parameters are in glob.getaprop(#theParams) |
|---|
| 11 | -- |
|---|
| 12 | -- REQUIRES: |
|---|
| 13 | -- script "aleXtrasMovieScript" as provider for library scripts -> xscr() |
|---|
| 14 | -- script "commonMovieScript" -- standard handlers -> here to get the globallist -> mGetGlobalList() |
|---|
| 15 | -- USAGE: |
|---|
| 16 | -- |
|---|
| 17 | -- NOTES: |
|---|
| 18 | -- This handler used to be in "thisMovieScript", but due to a scope bug with calling handlers |
|---|
| 19 | -- in other movies -> tell the stage unfortunately this doesn't fix the problem. |
|---|
| 20 | -- I have to investigate later WHY... so calling handlers, which are in this movie will fail |
|---|
| 21 | ----------------------------------- |
|---|
| 22 | |
|---|
| 23 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 24 | on _____________________PROCESS_COMMAND |
|---|
| 25 | end |
|---|
| 26 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 27 | |
|---|
| 28 | on mDoCmd dto, dto2 |
|---|
| 29 | |
|---|
| 30 | reservedHandlerList = [] |
|---|
| 31 | repeat with mscriptName in ["doCommandMovieScript", "thisMoviesScript", "convert_Lingo_2_CSS_Html"] |
|---|
| 32 | li = (script mscriptName).handlers() |
|---|
| 33 | if listP(li) then |
|---|
| 34 | repeat with n = count(li) down to 1 |
|---|
| 35 | reservedHandlerList.add(string(li[n])) |
|---|
| 36 | end repeat |
|---|
| 37 | end if |
|---|
| 38 | end repeat |
|---|
| 39 | |
|---|
| 40 | if ilk(dto) = #timeout then dto.forget() |
|---|
| 41 | if ilk(dto2) = #timeout then dto2.forget() |
|---|
| 42 | |
|---|
| 43 | global gRetVal |
|---|
| 44 | glob = call(#mGetGlobalList, mGetXScript()) |
|---|
| 45 | |
|---|
| 46 | skipFirstSpace = 0 |
|---|
| 47 | |
|---|
| 48 | inst = glob.getaprop(#theTargetInstance) |
|---|
| 49 | if ilk(inst) = #instance then |
|---|
| 50 | theMemberName = glob.getaprop(#theMemberName) |
|---|
| 51 | if glob.getaprop(#copy2ClipBoard) = 2 then |
|---|
| 52 | |
|---|
| 53 | ----------- alex syntax (I have my own "global handler" to create scriptinstances differently): |
|---|
| 54 | -- dostr = "call(#" & symbol(glob.getaprop(#cmd)) & ", mGetXscript(#" & theMemberName & ")," |
|---|
| 55 | if string(theMemberName) = "commonMovieScript" then |
|---|
| 56 | dostr = "xscr()." & glob.getaprop(#cmd) & "(" |
|---|
| 57 | else |
|---|
| 58 | dostr = "xscr(#" & theMemberName & ")." & glob.getaprop(#cmd) & "(" |
|---|
| 59 | end if |
|---|
| 60 | skipFirstSpace = 1 |
|---|
| 61 | del = 0 |
|---|
| 62 | else if glob.getaprop(#copy2ClipBoard) = 1 then |
|---|
| 63 | ----------- standard syntax, create new script instance for each call (this is NOT the optimized way !) |
|---|
| 64 | dostr = "call(#" & symbol(glob.getaprop(#cmd)) & ", new(script " & QUOTE & theMemberName & QUOTE & ")," |
|---|
| 65 | |
|---|
| 66 | ----------- better: store the intsance in a variable and reuse it (you will need to delete the new(script foo) lines) |
|---|
| 67 | -- dostr = "theScriptInstance = new(script " & QUOTE & theMemberName & QUOTE & ")" & RETURN & "call(#" & symbol(glob.getaprop(#cmd)) & ", theScriptInstance," |
|---|
| 68 | del = 1 |
|---|
| 69 | else |
|---|
| 70 | dostr = "call(#" & symbol(glob.getaprop(#cmd)) & ", [inst]," |
|---|
| 71 | del = 1 |
|---|
| 72 | end if |
|---|
| 73 | |
|---|
| 74 | else |
|---|
| 75 | |
|---|
| 76 | if glob.getaprop(#isBehavior) = 1 then |
|---|
| 77 | theParams = glob.getaprop(#theParams) |
|---|
| 78 | sprnum = theParams.getaprop("spritenum") |
|---|
| 79 | if length(string(sprnum)) < 1 then |
|---|
| 80 | sprnum = 0 |
|---|
| 81 | else if not(integerP(integer(sprnum))) then |
|---|
| 82 | sprnum = QUOTE & sprnum & QUOTE |
|---|
| 83 | end if |
|---|
| 84 | theParams.deleteprop("spritenum") |
|---|
| 85 | |
|---|
| 86 | dostr = "sendSprite(" & sprnum & ", #" & glob.getaprop(#cmd) & "," |
|---|
| 87 | del = 1 |
|---|
| 88 | else |
|---|
| 89 | dostr = glob.getaprop(#cmd) & "(" |
|---|
| 90 | skipFirstSpace = 1 |
|---|
| 91 | del = 0 |
|---|
| 92 | end if |
|---|
| 93 | end if |
|---|
| 94 | |
|---|
| 95 | theParams = glob.getaprop(#theParams) |
|---|
| 96 | if theParams.count then |
|---|
| 97 | repeat with thisParam in theParams |
|---|
| 98 | |
|---|
| 99 | ------- @@ is reserved to force treatment as string in any case |
|---|
| 100 | ------- sometimes (esp. svn commit messages) we do not want any evaluation of the parameter |
|---|
| 101 | if char 1 to 2 of string(thisParam) = "@@" then |
|---|
| 102 | thisParam = string(thisParam) |
|---|
| 103 | delete char 1 to 2 of thisParam |
|---|
| 104 | theVal = void |
|---|
| 105 | else |
|---|
| 106 | theVal = value(thisParam) |
|---|
| 107 | end if |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | if voidP(theVal) then |
|---|
| 111 | if (string(thisParam)).word.count > 0 then |
|---|
| 112 | if skipFirstSpace = 1 then |
|---|
| 113 | put QUOTE&thisParam"E&"," after dostr |
|---|
| 114 | skipFirstSpace = 0 |
|---|
| 115 | else |
|---|
| 116 | put " ""E&thisParam"E&"," after dostr |
|---|
| 117 | end if |
|---|
| 118 | else |
|---|
| 119 | put " void," after dostr |
|---|
| 120 | end if |
|---|
| 121 | |
|---|
| 122 | else |
|---|
| 123 | if length(string(thisParam)) > 0 then |
|---|
| 124 | if skipFirstSpace = 1 then |
|---|
| 125 | put thisParam&"," after dostr |
|---|
| 126 | skipFirstSpace = 0 |
|---|
| 127 | else |
|---|
| 128 | put " "&thisParam&"," after dostr |
|---|
| 129 | end if |
|---|
| 130 | else |
|---|
| 131 | put " void," after dostr |
|---|
| 132 | end if |
|---|
| 133 | |
|---|
| 134 | end if |
|---|
| 135 | |
|---|
| 136 | del = 1 |
|---|
| 137 | |
|---|
| 138 | end repeat |
|---|
| 139 | |
|---|
| 140 | end if |
|---|
| 141 | if del then delete the last char of dostr |
|---|
| 142 | |
|---|
| 143 | put ")" after dostr |
|---|
| 144 | |
|---|
| 145 | if (glob.getaprop(#copy2ClipBoard) = 1) or (glob.getaprop(#copy2ClipBoard) = 2) then |
|---|
| 146 | put "theResult = " before dostr |
|---|
| 147 | |
|---|
| 148 | member("pastefeld").text = dostr |
|---|
| 149 | copyToClipBoard(member("pastefeld")) |
|---|
| 150 | |
|---|
| 151 | else |
|---|
| 152 | |
|---|
| 153 | if reservedHandlerList.getPos(string(symbol(glob.getaprop(#cmd)))) > 0 then |
|---|
| 154 | alert "Sorry due to a bug in director I can't call handlers, which appear in moviescripts of this tool miaw themselves: " & glob.getaprop(#cmd) |
|---|
| 155 | exit |
|---|
| 156 | end if |
|---|
| 157 | |
|---|
| 158 | tell the stage |
|---|
| 159 | |
|---|
| 160 | res = the result |
|---|
| 161 | do dostr |
|---|
| 162 | if the result <> res then |
|---|
| 163 | gRetVal = the result |
|---|
| 164 | if (string(gRetVal)).length < 100 then put gRetVal |
|---|
| 165 | else put "Too many chars to put in the message window. Get the result from the global variable gRetVal"&RETURN&"put gRetVal"&RETURN |
|---|
| 166 | end if |
|---|
| 167 | end tell |
|---|
| 168 | end if |
|---|
| 169 | |
|---|
| 170 | end |
|---|