mIRC Homepage
Posted By: Dizkonnekted Dynamic popups with a difference? - 14/05/04 09:33 AM
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
Posted By: tidy_trax Re: Dynamic popups with a difference? - 14/05/04 10:15 AM
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
Posted By: Dizkonnekted Re: Dynamic popups with a difference? - 14/05/04 03:11 PM
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
Posted By: tidy_trax Re: Dynamic popups with a difference? - 14/05/04 03:31 PM
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.
Posted By: greeny Re: Dynamic popups with a difference? - 14/05/04 03:39 PM
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.
Posted By: Wolfie Re: Dynamic popups with a difference? - 14/05/04 07:40 PM
If that were to actually work, the /fopen and /fclose would have to be outside of the script.
Posted By: greeny Re: Dynamic popups with a difference? - 14/05/04 11:32 PM
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-
  }
}
© mIRC Discussion Forums