mIRC Home    About    Download    Register    News    Help

Print Thread
#237512 11/05/12 12:19 AM
Joined: May 2012
Posts: 2
E
Elmlea Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
E
Joined: May 2012
Posts: 2
Hello all,

I'm looking to add a bit to a script which asks for a list (imagine it's like a shopping list). It needs to start by asking for how many items when someone enters a command, which is easy enough, but then ask for a description of each individual item.

Starting it is easy, as it just needs something like

set %items $?="How many items?"

but I can't get it to count through the items one by one and ask for a description; I'm not sure how to define the variables. I can define another variable like %count = 1, and then run a simple loop that adds 1 to %count on every loop until %count = %items. But how do I define the output of that loop? I want each run through the loop to produce an output like %item1 then %item2 then %item3, so these can be all referenced later, but I defining the items as %item%count doesn't work.

As a more advanced feature, if the command is re-run later, I'd like it to add to the number of items; so if you set the number of items to 2, then define them, and then run the command again and set the number of items to 3, it'll just ask you for the 3rd item's description and preserve 1 and 2.

I'm sorry for the really wordy first post, and sorry to blunder in with a really irritating request, but I hope someone can help me!

Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
The use of inc maybe do the trick? You need to use a loop so why not use the same one for your count? set %item $+ %x test

If %x is 1, then the variable would look like %item1 test


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Link Copied to Clipboard