i want to execute a string with the execute comand but when i just insert one command i get an syntaxerror. The problem is that i dont know which type of commnd is in the string. How can i do this ? Here is a sample to show what i mean :
execute("is do print \"hallo\";end;"); -- prints hello
execute("print \"hallo\";"); -- error <- here i need something to change this
print execute(":string is do return \"hallo\";end;"); -- prints hello
I need this because I have a SocketServer with the following Callback Method and need to execute the SocketMessage
(SocketChannelNo: integer; SocketMessage : string)
print "executing: "+SocketMessage;
Solved! Go to Solution.
I would suggest that the socket never sends a message with "is do end". Then you could always put ":any is do " before the command and " end;" behind the command.
Look at this example:
is do local command1: string := "print \"hello\""; local command2: string := "return 42"; execute(to_str(":any is do ", command1, " end;")); execute(to_str(":any is do ", command2, " end;")); end;
the problem is i down know whitch message is without a "is do end". When i get a string to execute like "is do print "hallo";end;" i get a syntaxerror because "is do is do print "hallo";end;end;" doese not work
is there a method like isExecutable("")
This should solve your problem:
if executeSilent(to_str(":any is do ", command, " end;")) = void then execute(command); end;