4got Posted March 6, 2008 Posted March 6, 2008 HI to everybody..I'm new in this forum,my nick is 4got, I'm not english so please forgave me if in my post you find some errors...By the way I have a problem when I compare a variable and a string.This is the code: $Data = TCPReceive($ConnectedSocket) ;move the mesage in the variable $Data $compare=StringCompare($Data,"start",0) ;compare the string with the mesage If $compare=0 Then ;condition MsgBox(0,"Message","The message is start") ElseIf $Data >=0 then MsgBox(0, "Message", $Data) EndIf If someone could help me... thx
weaponx Posted March 6, 2008 Posted March 6, 2008 This has to be on one line: ElseIf $Data >=0 then ElseIf $Data >=0 then
4got Posted March 7, 2008 Author Posted March 7, 2008 This has to be on one line: ElseIf $Data >=0 then ElseIf $Data >=0 thenIt still doesn't work.. It always executes the second ifElseIf $Data >=0 thenMsgBox(0, "Message", $Data)EndIfI need that this program recognizes the command that I send. E.G if I send the command start the program will execute a certain operation and if I send another command it will do another operation.. I hope to be clear..
martin Posted March 7, 2008 Posted March 7, 2008 It still doesn't work.. It always executes the second ifElseIf $Data >=0 thenMsgBox(0, "Message", $Data)EndIfI need that this program recognizes the command that I send. E.G if I send the command start the program will execute a certain operation and if I send another command it will do another operation.. I hope to be clear..What does the MsgBox display for the string $Data? 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.
4got Posted March 8, 2008 Author Posted March 8, 2008 What does the MsgBox display for the string $Data?If I write "start" the MsgBox display "start".The compare doesn't work but the string is correct.
McGod Posted March 8, 2008 Posted March 8, 2008 If $Data = "start" Then [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u]
martin Posted March 8, 2008 Posted March 8, 2008 If I write "start" the MsgBox display "start".The compare doesn't work but the string is correct. Can't see why there is a problem. See what happens if you try this then $Data = TCPReceive($ConnectedSocket);move the mesage in the variable $Data $compare=StringInStr($Data,"start",0);test the string is in the message If $compare>0 Then;condition MsgBox(0,"Message","The message is start") ElseIf $Data >=0 then MsgBox(0, "Message", $Data) EndIf 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.
4got Posted March 10, 2008 Author Posted March 10, 2008 Now the program works but I have other 2 problems: -if I want to use a switch case can I put a string instead of a value? switch($Data) case "start" .... I tried this way but it didn't work..How can I do? -if I don't wanna see the icon of the autoit application when it runs in the application bar of windows what I have to do? Thx a lot to everybody who has answered to this post.
Developers Jos Posted March 11, 2008 Developers Posted March 11, 2008 should work fine ... what is the exact content of the variable $data ?Application bar ? do you mean systemtray ? (#NoTrayIcon) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
4got Posted March 12, 2008 Author Posted March 12, 2008 should work fine ... what is the exact content of the variable $data ?Application bar ? do you mean systemtray ? (#NoTrayIcon)In the variable $Data I put the message that is sent by means of the client program, in this case I've tried with the message "start" but it didn't work...Yes the systemtray...sorry...
martin Posted March 13, 2008 Posted March 13, 2008 Now the program works but I have other 2 problems: -if I want to use a switch case can I put a string instead of a value? switch($Data) case "start" .... I tried this way but it didn't work..How can I do? -if I don't wanna see the icon of the autoit application when it runs in the application bar of windows what I have to do? It shouldn't work based on what you found earlier because your original problem was that $Data was not equal to "start" for some reason and this was cured by using $compare=StringInStr($Data,"start",0);possibly some whitespace character in $Data It would probably have been better to find out what was in $data that was causing the problem and strip it out, try using $Data = StringStripWS($Data,8). Failing that, instead of switch use Select- Select Case StringInStr($Data,"start",0) > 0 ;something . . . 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.
4got Posted March 14, 2008 Author Posted March 14, 2008 It shouldn't work based on what you found earlier because your original problem was that $Data was not equal to "start" for some reason and this was cured by using $compare=StringInStr($Data,"start",0);possibly some whitespace character in $Data It would probably have been better to find out what was in $data that was causing the problem and strip it out, try using $Data = StringStripWS($Data,8). Failing that, instead of switch use Select- Select Case StringInStr($Data,"start",0) > 0 ;something . . .yes now it's perfect...when it will be complete I'll post it..thx to everybody
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