Jump to content

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


khui
 Share

Recommended Posts

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 > *

Link to comment
Share on other sites

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

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 > *

Link to comment
Share on other sites

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 > *

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...