Sign in to follow this  
Followers 0
phew

If does not work?

9 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Not sure if it works but try:

If $splitpacket[$i] == "@Q" Then

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

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


[center]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.[/center]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

[center]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.[/center]

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

doesn't work :)

but thanks for help

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

[center]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.[/center]

Share this post


Link to post
Share on other sites

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)?


[center]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.[/center]

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  
Followers 0