Jump to content

If does not work?


phew
 Share

Recommended Posts

EDIT: my bad, posted some **** :)

Global $recv = ""
Global $file = "names.ini"
Func getNames($socket, $recv)
 While (StringInStr($recv,"366") = 0)
      $recv = TCPRecv($socket, 32768) 
      If (StringInStr($recv,"353")) Then
          Global $i = 0
          Global $x = 0
            IniWrite($file, "NAMES", "", "")
            Dim $splitpacket[256]
            $splitpacket = StringSplit($recv, ' ')
            $x = UBound($splitpacket) -1
            For $i = 0 To $x Step 1
                                MsgBox(1, "", "THIS MSGBOX IS DISPLAYED") 
                If ($splitpacket[$i] = "@Q") Then
                                        MsgBox(1, "", "THIS ONE IS NOT DISPLAYED - WHY?")
                    ContinueLoop
                ElseIf ($splitpacket[$i] = "353") Then
                    ContinueLoop
                    Else
                    IniWriteSection($file, "NAMES", $splitpacket[$i])
                EndIf
                Next
        ; do something;)
      EndIf
 WEnd 
EndFunc

why isn't the If ($splitpacket[$i] = "@Q") Then... executed? it just writes IniWriteSection($file, "NAMES", $splitpacket[$i]) the data to the *.ini, so it executes the "else" but neither the "if" nor the "elseif".

any idea?

Edited by phew
Link to comment
Share on other sites

  • Moderators

How are you sending / receiving / reading the information.. ? What type of file/string are you sending?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Not sure if it works but try:

If $splitpacket[$i] == "@Q" Then
already tried that, didn't work either

How are you sending / receiving / reading the information.. ? What type of file/string are you sending?

$recv = TCPRecv($socket, 512)

so on channel join $recv is the following data:

:uNkC-19941!~ulcct@p549BAE03.dip0.t-ipconnect.de JOIN #vash
:stockholm.se.quakenet.org 332 uNkC-19941 #vash :naruto 364 win win win
:stockholm.se.quakenet.org 333 uNkC-19941 #vash Suzuran^_^ 1185573276
:stockholm.se.quakenet.org 353 uNkC-19941 @ #vash :uNkC-19941 @RACHE|NS @Aoshi|BNC @phew @roush0ff @Suzuran @b0x @|pi @Suzuran^_^ @bp @rigo @F1NEST @Q
:stockholm.se.quakenet.org 366 uNkC-19941 #vash :End of /NAMES list.

which i split into $splitpacket by $splitpacket = StringSplit($recv, ' ').

i want to filter out normal nicknames and write them into NAMES.INI in [NAMES] section, but somehow the

For $i = 0 To $x Step 1
   if $splitpacket[$i] = "BLA" then
        continueloop
   elseif $splitpacket[$i] = "@Q" then
                 continueloop
   else
                 IniWriteSection($file, "NAMES", $splitpacket[$i])
endif
    Next

IF does not work :)

EDIT:

also tried

Switch $splitpacket[$i]
                    Case "@Q"
                        MsgBox(1, "", "@Q found! Ignoring!")
                        ContinueCase
                    Case Else
                        IniWriteSection($file, "NAMES", $splitpacket[$i])
                        ExitLoop
                EndSwitch

instead of the If, ddidn't work either.

same with Select Case $splitpacket[$i] = "@Q"

slowly i'm becoming desperate :P

Edited by phew
Link to comment
Share on other sites

  • Moderators

Try this... Replace all of your TCPRecv's with _myTCPRecv(..) and all of your TCPSend's with _myTCPSend(...)... in both the client and the server scripts.

Then add the below 2 functions to your scripts... and tell me if it helped receive the correct data.

Func _myTCPRecv($nMainSocket, $nMaxLen, $iFlag = 0)
    Local $sTCPRecv = TCPRecv($nMainSocket, $nMaxLen, $iFlag)
    If @error Then Return SetError(@error, 0, "")
    Return BinaryToString('0x' & $sTCPRecv)
EndFunc
    
Func _myTCPSend($nMainSocket, $sData)
    Return TCPSend($nMainSocket, StringTrimLeft( _
        StringToBinary($sData), 2))
EndFunc

Edit:

Fixed _myTCPRecv to catch and return the right errors if there are any so it doesn't break those scripts that actually error check.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Try this... Replace all of your TCPRecv's with _myTCPRecv(..) and all of your TCPSend's with _myTCPSend(...)... in both the client and the server scripts.

Then add the below 2 functions to your scripts... and tell me if it helped receive the correct data.

Func _myTCPRecv($nMainSocket, $nMaxLen, $iFlag = 0)
    Return BinaryToString('0x' & TCPRecv($nMainSocket, $nMaxLen, $iFlag))
EndFunc
    
Func _myTCPSend($nMainSocket, $sData)
    Return TCPSend($nMainSocket, StringTrimLeft( _
        StringToBinary($sData), 2))
EndFunc
thanks, i'll try it later g2g offline for a while,

greetings

Link to comment
Share on other sites

  • Moderators

doesn't work :)

but thanks for help

"Doesn't work" doesn't help in trying to help you :P...

What was the output you got this time?

Give me the received string exactly once you've sent it, then explain exactly from that received string what you'd like to accomplish.

(If you could do it with both your regular TCP method, and the one that I provided that'd be great).

Edit:

When you have a string like this, tell me exactly what data you want from it... Not what you "think" you should do string manipulation wise, but what "Exact" data would you like to strip from here to perform other tasks.

:uNkC-19941!~ulcct@p549BAE03.dip0.t-ipconnect.de JOIN #vash

:stockholm.se.quakenet.org 332 uNkC-19941 #vash :naruto 364 win win win

:stockholm.se.quakenet.org 333 uNkC-19941 #vash Suzuran^_^ 1185573276

:stockholm.se.quakenet.org 353 uNkC-19941 @ #vash :uNkC-19941 @RACHE|NS @Aoshi|BNC @phew @roush0ff @Suzuran @b0x @|pi @Suzuran^_^ @bp @rigo @F1NEST @Q

:stockholm.se.quakenet.org 366 uNkC-19941 #vash :End of /NAMES list.

Edit2:

Let's assume it's the names:

#include <array.au3>
$sString = _myTCPRecv(etc...)
$aNames = StringRegExp($sString, '(?s)(?i)\@(\w+)', 3)
_ArrayDisplay($aNames)
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Going to assume by your lack of response... that you were abducted by aliens, or the above solution worked for you (you were just looking for names)?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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