mIRC Home    About    Download    Register    News    Help

Print Thread
Dynamic popups with a difference? #82950 14/05/04 09:33 AM
Joined: Nov 2003
Posts: 46
D
Dizkonnekted Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Nov 2003
Posts: 46
Hi All,

I'm just wondering if it is possible to make a menu from the contents of a file, say an .ini or .txt file, and if it is possible what is the structure to get it to display??

Now I am not talking about making a menu like having a file with 'menu channel {
commands here
}'
I want to do it dynamically, say I have .txt file full of nicks, I would like to be able to display those nicks in a popup, but given that the .txt file is always changing the popup menu should reflect that. I have an idea how to do it myself but would be interested in hearing your opinions.

I hope this all makes sense
If not ask me.

Regards,
Diz


Dizkonnekted from reality....!
Re: Dynamic popups with a difference? #82951 14/05/04 10:15 AM
Joined: Nov 2003
Posts: 2,327
T
tidy_trax Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
alias popup {
if $1 == begin { return - }
elseif $1 isnum 1- { return $read(<file>,$1) $+ : echo -a $read(<file>,$1) }
elseif $1 == end { return - }
}
menu channel {
file
.$submenu($popup($1))
}


/help $submenu


New username: hixxy
Re: Dynamic popups with a difference? #82952 14/05/04 03:11 PM
Joined: Nov 2003
Posts: 46
D
Dizkonnekted Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Nov 2003
Posts: 46
Hi tidy_trax,
Excellent stuff, short and sweet works a treat! grin
I have one small request, can you ;comment that for me please? I can see how it works, but I dont fully understand it.

Some commenting would help me grasp it, another quick request also, with the resulting popup being displayed, where would I add a little code to add functionality to the displayed result, ie make it DO something?

Thanks again tidy_trax,
Diz


Dizkonnekted from reality....!
Re: Dynamic popups with a difference? #82953 14/05/04 03:31 PM
Joined: Nov 2003
Posts: 2,327
T
tidy_trax Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Code:
alias popup { 
  if $1 == begin { return - }
  ;if $1 is begin, use - to start the popup.
  elseif $1 isnum 1- { return $read(&lt;file&gt;,$1) $+ : echo -a $read(&lt;file&gt;,$1) }
  ;if $1 is a number from 1 and onwards, return the $1'th line in &lt;file&gt;, and echo it.
  elseif $1 == end { return - }
  ; if $1 is end, use - to end the popup.
}
menu channel {
  file
  .$submenu($popup($1))
}


elseif $1 isnum 1- { return $read(<file>,$1) $+ : echo -a $read(<file>,$1) }

everything after ":" in the above line is what you want to do, $1 is always either "begin", "end" or a number in $submenu, unless $popup() (or any other alias you choose to use) uses /tokenize.

So:
return $read(<file>,$1) $+ :
That makes the popup name
echo -a $read(<file>,$1)
Is what you want the popup to do when you click it.


New username: hixxy
Re: Dynamic popups with a difference? #82954 14/05/04 03:39 PM
Joined: Dec 2002
Posts: 230
G
greeny Offline
Fjord artisan
Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
Since using $read over and over can become slow, I'd suggest using /fopen in the "begin event", $fread when returning the popup items and /fclose in the end though.

Re: Dynamic popups with a difference? #82955 14/05/04 07:40 PM
Joined: Aug 2003
Posts: 325
W
Wolfie Offline
Fjord artisan
Offline
Fjord artisan
W
Joined: Aug 2003
Posts: 325
If that were to actually work, the /fopen and /fclose would have to be outside of the script.

Re: Dynamic popups with a difference? #82956 14/05/04 11:32 PM
Joined: Dec 2002
Posts: 230
G
greeny Offline
Fjord artisan
Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
Huh? No... seems like you didn't get my point.
Here's an example of a submenu I'm using to list some apps in my popups:
Code:
sub.cprog {
  if ($1 == begin) { .fopen cprog script\txt\cprog.txt }
  elseif ($1 == end) { .fclose cprog }
  else {
    if (!$feof) { tokenize 160 $fread(cprog) }
    else { return }
    return $+(&amp;,$1,:run) -p $2-
  }
}