Jump to content
Sign in to follow this  
khui

Execute("$variable=3;MsgBox(1,"",$variable);")

Recommended Posts

khui

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 by khui

i > *

Share this post


Link to post
Share on other sites
martin

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.

Share this post


Link to post
Share on other sites
khui

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.

I had a MsgBox that told me what the buffer we're and i couldnt get fix it anyway :)


i > *

Share this post


Link to post
Share on other sites
khui

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 by khui

i > *

Share this post


Link to post
Share on other sites
khui

Seriously, no one knows? Is this some kind of bug?

20 views and one answer, thats a shame.


i > *

Share this post


Link to post
Share on other sites
dantay9

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 by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites
Richard Robertson

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×