mIRC Home    About    Download    Register    News    Help

Print Thread
goto loop question #213818 09/07/09 01:55 PM
Joined: Aug 2004
Posts: 423
C
clutz1572 Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
i haven't actually had the opportunity to test this yet.. but, i'm not sure if this would work as it is.. what i'm trying to do is loop search through a hash table to check for a match in one list, if a match is found then it gets skipped and logged in a custom window as being skipped in the custom window and stop. if no match is found then continue on to the next step in the loop which posts the results found...

the second step i'm not concerned about as i know it works.. i'm more interested in the first part list as skip in this example.. my use of the HALT command, i'm not sure if it's proper.

Code:
 :skip
    if ($hfind(skip,%name,1,W)) {  
      /window -zk0 @window | /aline -p @window $timestamp 4Skiped  ->3 %name 
      halt
    }
    else { goto blah }
    :blah
    if ($hfind(sometable,%name,1,W)) {  
      /window -zk0 @window | /aline -p @window $timestamp found 12[ $+ %source $+ 12 ->3 %name 1 in 7 %section
    "some commands here"
    }
    else { halt }
   :end


can anyone give me some info on this?... thank in advance

Re: goto loop question [Re: clutz1572] #213821 09/07/09 02:53 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Hum, a bit ambiguous. It doesn't really sound like a loop but an
Code:
if (found in skiptable) { aline and stop }
elseif (found in sometable) { aline and do stuff }

I don't know whether or not you need the :skip and :end goto points - and the structure this code is embedded into.

- You can /return inside an alias. If the current alias was called by another alias, the current alias is not processed any further, BUT the alias/event that called the current alias will keep running.
- If instead you /halt inside the alias, the curent alias AND the alias/event that called the current alias won't be processed any furhter.
- If your alias was not called by another alias/event, or if there would be no further code in that alias/event, and if there would be no further code after your :end goto point, a if-else construction (without "stopping" commands) would suffice.

Assuming that the :skip and :end goto points are required, you could do e.g.
Code:
  :skip

  if ($hfind(skip,%name,1,W)) {
    ; if window "@window" doesn't exist so far, create it
    window -zk0 @window
    ; aline the match to this window
    aline -p @window $timestamp skipped %name ....

   ; break out of the current alias (don't process code after :end)
   return or halt
  }

  elseif ($hfind(sometable,%name,1,W)) {
    ; if window "@window" doesn't exist so far, create it
    window -zk0 @window
    ; aline the match to this window
    aline -p @window $timestamp found %name ....
    ; do other stuff
    some commands here  
  }

  :end
  ; whatever follows here won't be executed if the first hfind was successful
  ; if you don't use this goto point, you can as well put the code into the elseif-part...

(Hope I got you right)

Re: goto loop question [Re: Horstl] #213829 09/07/09 07:28 PM
Joined: Mar 2006
Posts: 393
T
The_JD Offline
Fjord artisan
Offline
Fjord artisan
T
Joined: Mar 2006
Posts: 393
Code:
alias co.listhash {
  co.while $hget(0) .timer -m 1 1 echo -a $chr(2) $ $+ + $ $+ hget(&i) $ $+ + $chr(2) $chr(124) co.while $ $+ hget(&i,0).item echo -a $ $ $ $+ + + hget(&i,& $ $+ + i).item = $ $ $ $+ + + hget(&i,& $ $+ + i).data
}

alias co.while {
  var %i 1
  while (%i <= $1) {
    $eval($replace($2-,&i,%i),2)
    inc %i
  }
}

You could probably do what you want by modifying this a little
Usage: /co.listhash

Last edited by The_JD; 09/07/09 07:52 PM.

[02:16] * Titanic has quit IRC (Excess Flood)
Re: goto loop question [Re: Horstl] #213861 10/07/09 12:07 PM
Joined: Aug 2004
Posts: 423
C
clutz1572 Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
yes Horstl, i think that would work out better.. as i din't even think about making a combination of the points.. but, yes i chose a goto loop because my script is setup in such a way that it has many initial triggers that if matched, activate different points in the loop and each point does slightly different things.. so you suggestion along with info from another post i saw, should help reduce some coding and hopefully make it more efficient.. laugh

thank you for your suggestions..

Re: goto loop question [Re: The_JD] #213862 10/07/09 12:11 PM
Joined: Aug 2004
Posts: 423
C
clutz1572 Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
The_JD,

thank you for responding... however though.. it's been a while since i last scripted anything major, so my scripting skills are rusty. having said that, i am having some trouble trying to figure out your code there.... i follow it somewhat but, but the extensive use of the $ character is throwing me off a bit.. lol


Re: goto loop question [Re: clutz1572] #213874 10/07/09 10:17 PM
Joined: Mar 2006
Posts: 393
T
The_JD Offline
Fjord artisan
Offline
Fjord artisan
T
Joined: Mar 2006
Posts: 393
Don't worry, It confuses the hell out of me, as well. (Must have been drunk when I wrote it)


[02:16] * Titanic has quit IRC (Excess Flood)