| run a script in a designated location (with an optional search path) | 2nd coding section allows changes to the bytecode after compilation of the script do_in :: { params :: * bytecodeString :: scriptString :: string rtrn :: c1 :: bytecode_word :: bytecode_words_num :: bc0 :: bcf :: int target :: searchPath :: * no_path :: { * }, default_path :: { } myname := "do_in" compiledCode :: {} code if (myname == "compile_and_do_in") then ( trap(remove scriptSpace) scriptSpace :: {} (scriptSpace< 4 then throw(1) if top(args) == 0 then target = @root else target = @args[1] if top(args) >= 2 then ( if (trap(if args[2] == @nothing then throw(1)) /= passed) then searchPath = @no_path else searchPath = @args[2] ) else searchPath = @default_path if myname == "compile_and_do_in" then ( { scriptString } = scriptSpace remove scriptSpace ) ) /= passed then ( print("usage: ", myname, "(target [, { search path } [, { script args } [, { bytecode_mod args }]]]; ") printl("script to run [; script to modify BytecodeArray[]])") target = @searchPath = @nothing return ) remove params | the user may want to work in this variable, so clean it out params :: { bytecodeWords :: [1] int } | do_in() extracts the compiled code from the args.. if myname == "do_in" then ( params.bytecodeWords[*] =! (bytecodeString = bytecode(args)) bytecode_words_num = top(params.bytecodeWords) bytecode_word = 1 bc0 = bcf = 0 { while bytecode_word <= bytecode_words_num do ( if (params.bytecodeWords[bytecode_word] == 4 or params.bytecodeWords[bytecode_word] == 0) then ( if bc0 == 0 then ( bc0 = bytecode_word if params.bytecodeWords[bytecode_word] == 0 then return ) else ( bcf = bytecode_word return ) ) disassemble(bytecodeString, *, bytecode_word) ) } if bcf /= 0 then & remove params.bytecodeWords[] remove params.bytecodeWords[<1, bc0>] params.bytecodeWords[+top+1] = 0 ) | .. whereas compile_and_do_in() compiles the script string else ( rtrn = trap( ; bytecodeString = compile(scriptString)) if rtrn /= passed then return params.bytecodeWords[*] =! bytecodeString ) | allow the user to modify the compiled bytecode if (trap(if args[4] == @nothing then throw(1)) == passed) then & (params<= 3 then ( if trap(if args[3] == @nothing then throw(1)) == passed then ( return (target<