khui Posted October 11, 2009 Share Posted October 11, 2009 (edited) Hello fellas, I'm trying to execute a variable and then MsgBoxing it. $buffer = TCPRecv($MainSocket,999999) $bits = StringSplit($buffer,";") For $a = 1 To $bits[0] -1 $exec = Execute($bits[$a]) Next $buffer = "" Alright, so o split into strings at ";". When i write "MsgBox(1,"","hello");" to the socket, it works. When i write "$a=3;" to the socket, it doesn't do anyting visible obviously. When i write "$a=3;MsgBox(1,"",$a);" to the socket, it opens a msgbox displaying a number, but It's the wrong number, sometimes it says "1" and sometimes "4" ect. If you know how to make this whole thing work, please tell me Thank you for reading. Edited October 11, 2009 by khui i > * Link to comment Share on other sites More sharing options...
martin Posted October 11, 2009 Share Posted October 11, 2009 Hello fellas, I'm trying to execute a variable and then MsgBoxing it. $buffer = TCPRecv($MainSocket,999999) $bits = StringSplit($buffer,";") For $a = 1 To $bits[0] -1 $exec = Execute($bits[$a]) Next $buffer = "" Alright, so o split into strings at ";". When i write "MsgBox(1,"","hello");" to the socket, it works. When i write "$a=3;" to the socket, it doesn't do anyting visible obviously. When i write "$a=3;MsgBox(1,"",$a);" to the socket, it opens a msgbox displaying a number, but It's the wrong number, sometimes it says "1" and sometimes "4" ect. If you know how to make this whole thing work, please tell me Thank you for reading. You need to see what $buffer is to find out what's happening. Add a line ConsoleWrite($buffer & @CRLF) after TCPRcv. If $buffer = '' then you should shouldn't be processing it so try TCPRecv again until you get a valid string. Look at the example in the help for TCPRecv. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
khui Posted October 11, 2009 Author Share Posted October 11, 2009 You need to see what $buffer is to find out what's happening. Add a lineConsoleWrite($buffer & @CRLF)after TCPRcv.If $buffer = '' then you should shouldn't be processing it so try TCPRecv again until you get a valid string. Look at the example in the help for TCPRecv.I had a MsgBox that told me what the buffer we're and i couldnt get fix it anyway i > * Link to comment Share on other sites More sharing options...
khui Posted October 11, 2009 Author Share Posted October 11, 2009 (edited) I had a MsgBox that told me what the buffer we're and i couldnt get fix it anyway Lets say the buffer contained: $a=4;MsgBox(1,"",$a); The msgbox got printed, but instead of "4" it printed "2". Now i know why it printed 2 duh i used $a as a counter in my For-loop Well anyway, when i tried with $sa=3;MsgBox(1,"",$sa); It didnt print anything. The ConsoleWrite($bits[$a] & @CRLF) said: $sa=4 MsgBox(1,"",$sa) Edited October 11, 2009 by khui i > * Link to comment Share on other sites More sharing options...
khui Posted October 11, 2009 Author Share Posted October 11, 2009 *bump* i > * Link to comment Share on other sites More sharing options...
khui Posted October 11, 2009 Author Share Posted October 11, 2009 Seriously, no one knows? Is this some kind of bug? 20 views and one answer, thats a shame. i > * Link to comment Share on other sites More sharing options...
dantay9 Posted October 11, 2009 Share Posted October 11, 2009 (edited) You are extremely impatient. Wait at least 24 hours before bumping your post. You are deterring people with that attitude of yours. Firstly, you doubled up on double quotes, which messes with the syntax. Secondly, you will probably have to use an if statement to sort through the returns. Here is an example that you can modify. It is a bit messy where I parsed the strings, but you get the idea. $buffer = "$sa=3;MsgBox(1,'',$sa);" $bits = StringSplit($buffer, ";") For $a = 1 To $bits[0] - 1 If StringLeft($bits[$a], 1) == "{:content:}quot; Then Assign(StringMid($bits[$a], 2, StringInStr($bits[$a], "=") - 2), StringRight($bits[$a], StringLen($bits[$a]) - StringInStr($bits[$a], "="))) Else Execute($bits[$a]) EndIf Next Edited October 11, 2009 by dantay9 Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 11, 2009 Share Posted October 11, 2009 If you want to execute a script sent over TCP functions, save it to a file and run it that way. Execute isn't meant to run every kind of code. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now