Jump to content

If and elseif


Recommended Posts

Hi all

i need a bit of help on the IF in my script

;---click button-----------------------------------------------

If $msg = $Button_12 then

;-----send data from input to edit--------------------------------------------

GUICtrlSetData($Edit_10, GUICtrlRead($Edit_10) & GUICtrlRead($Input_11) & @CRLF )

i'm stuck here i need to read $Input_11 it's a input if it Contains "/" i then need to use the StringTrimleft to

rid the / before it hits the TCPSend then elseif the input dose not Contain "/" i just need it to

TCPSend($socket,"PRIVMSG:"&GUICtrlRead($Input_11)&@LF)

button $Button_12 is a send button

any ideas on this ?

i was thinking of using the Select /EndSelect on this but i just don't know

thank you

michael

If GUICtrlRead($Input_11) = "/" Then
$re = StringTrimleft($Input_11, 1)
TCPSend( $socket, $re)


elseif  GUICtrlRead($Input_11) = "" Then
TCPSend($socket,"PRIVMSG:"&GUICtrlRead($Input_11)&@LF)
endif
endif
Link to comment
Share on other sites

try:

If StringRight(GUICtrlRead($Input_11),1) = "/" Then
i don't understand this

If StringRight(GUICtrlRead($Input_11),1) = "/" Then

i'm trying to trim the / of the word for Example /hi i need to trim the / so it's just hi

my bit of code

if  GUICtrlRead($Input_11) = "/" Then
$result = StringTrimLeft($Input_11), 3) 

MsgBox(4096, "Test",$result , 0)
Link to comment
Share on other sites

  • Developers

i don't understand this

If StringRight(GUICtrlRead($Input_11),1) = "/" Then

i'm trying to trim the / of the word for Example /hi i need to trim the / so it's just hi

my bit of code

if  GUICtrlRead($Input_11) = "/" Then
$result = StringTrimLeft($Input_11), 3) 

MsgBox(4096, "Test",$result , 0)
Thought you wanted to check for trailing "/"

To trim a leading slash you can:

$result = GUICtrlRead($Input_11)
If StringLeft($result ,1) = "/" Then
    $result = StringTrimLeft($result ,1) 
EndIf
Edited by JdeB

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.
  :)

Link to comment
Share on other sites

i don't understand this

If StringRight(GUICtrlRead($Input_11),1) = "/" Then

i'm trying to trim the / of the word for Example /hi i need to trim the / so it's just hi

my bit of code

if  GUICtrlRead($Input_11) = "/" Then
$result = StringTrimLeft($Input_11), 3) 

MsgBox(4096, "Test",$result , 0)
Try

if  StringRight(GUICtrlRead($Input_11),1) = "/" Then
$result = StringTrimLeft($Input_11), 3) 

MsgBox(4096, "Test",$result , 0)

What it does is read the first letter of the input and checks to see it is "/". If it is it will then strip it off.

Edit-

Beaten again, must learn to type faster. :"> :">

Edited by BigDod


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Try

if  StringRight(GUICtrlRead($Input_11),1) = "/" Then
$result = StringTrimLeft($Input_11), 3) 

MsgBox(4096, "Test",$result , 0)

What it does is read the first letter of the input and checks to see it is "/". If it is it will then strip it off.

Edit-

Beaten again, must learn to type faster. :"> :">

thank you guys fo the help would be lost without it

your examples are working but for some reson it will not send tcp

but if i use a msgbox as a test it will work the / will be gone so i just have to fig out why it will not send tcp .

If $msg = $Button_12 Then 
$result = GUICtrlRead($Input_11)
If StringLeft($result ,1) = "/" Then
    $result = StringTrimLeft($result ,1) 
EndIf
TCPSend($socket,$result)
Link to comment
Share on other sites

Did you define $socket as a TCPConnect socketID somewhere in your script?

Like:

$socket = TCPConnect("192.168.1.1",23)

Here's the helpfile:

TCPSend ( socket, data ) 

Parameters
-socket: The main socket identifier (SocketID) as returned by a TCPConnect function. 
-data: binary/string to be send to the connected socket
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...