Page 1 of 1 1
Topic Options
#130832 - 2004-12-08 10:02 AM Automatically create variables
bcambre Offline
Fresh Scripter

Registered: 2004-12-07
Posts: 14
Hi,

I would like to make a menu with printers to select. The number of printers there is dependent of the array (sometimes there are 3 or 4 or 5 printers to choose from).
This works fine, I can make a list, but when I want to choose from that list, the printer I select should also be stored in a variable to use in the command line used to install a printer.

For Each $Item in $Array
at ( 4+$count,2) $Array[$count]
$count=$count+1
Next

This generates the list, but I need for example $var1 and $var2 to be filled in with the value from $item.

Does this make sense and is this possible ?

thanks
_________________________
bram

Top
#130833 - 2004-12-08 10:47 AM Re: Automatically create variables
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Here is one way to do it:

Code:
Break ON

CLS

; Assign dummy printer list
$aPrinters="Marketing laser","IT Multifunction","Reception Colour Copier"
$aPrinterURL="\\server\mkt_las01","\\server\it_mf01","\\server\recp_cc01"

For $iCount = 0 To Ubound($aPrinters)
At(4+$iCount,2) $iCount+1 ": " $aPrinters[$iCount]
Next

While Not $vSelection
At(5+$iCount,2) "Please enter a number between 1 and " $iCount ": "
At(5+$iCount,2) "Please enter a number between 1 and " $iCount ": "
Gets $vSelection
At(6+$iCount,2) " "
$vSelection=CInt($vSelection)
If $vSelection < 1 OR $vSelection > $iCount
Beep
$vSelection=0
At(6+$iCount,2) "**Invalid selection - please try again!"
EndIf
Loop

@CRLF "You selected printer # :" $vSelection @CRLF
" name :" $aPrinters[$vSelection-1] @CRLF
" URL :" $aPrinterURL[$vSelection-1] @CRLF

Exit 0


Top
#130834 - 2004-12-08 11:16 AM Re: Automatically create variables
bcambre Offline
Fresh Scripter

Registered: 2004-12-07
Posts: 14
that's a big help. thanks

_________________________
bram

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.051 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org