Page 1 of 1 1
Topic Options
#60016 - 2001-10-22 12:13 AM MENU FOR PRINTERS AVAILABLE!!!
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
I would like to write a script to make a menu available for the users at logon time for adding network printers. The first menu, displaying the department names. Depending on the selection of the department, I would like to list the printers available for the particular department as the second menu. And depending on the printer selected I would like to map that printer for the user as the network printer. I was trying something but could not get anywhere.
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#60017 - 2001-10-21 06:50 PM Re: MENU FOR PRINTERS AVAILABLE!!!
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Hi Saleem,

One way is to build Windows-like textboxes with KiXtart's AT() and BOX() functions ... then read the keyboard and allow the user to make a selection :

Here's an quicky User Defined Function called MenuChoice (hope your running KiXtart 4.0) ...


You call it like this:

$choice = MenuChoice($prompt,$menu,x,y)

where:

$prompt is the window title to display
$menu is an array of strings (choices)
$x is the left position of the window (col)
$y is the top position of window (row)

and it goes like this:


code:

break on


$Departments = "North","South","East","West"


$NorthPrinters = "North1","North2","North3"
$SouthPrinters = "South1","South2"
$EastPrinters = "East1","East2","East3","East4","East5","East6"
$WestPrinters = "West1","West2"


CLS


$Dept = MenuChoice("Department ?",$Departments,5,5)


Select
Case $Dept = "North"
$Printer = MenuChoice("North Printer ?",$NorthPrinters,8,8)
case $Dept = "South"
$Printer = MenuChoice("South Printer ?",$SouthPrinters,8,8)
case $Dept = "East"
$Printer = MenuChoice("East Printer ?",$EastPrinters,8,8)
case $Dept = "West"
$Printer = MenuChoice("West ?",$WestPrinters,8,8)
EndSelect


If $Printer
?"You selected $Printer from the $Dept department"
Endif


exit 1

function MenuChoice($prompt,$menu,$x,$y)
;
; prompt - window caption
; menu - array of strings (choices)
; x - left position of window (col)
; y - top position of window (row)
;
dim $option,$n,$current,$previous,$key
dim $height,$width
$height = ubound($menu)+2
$width = len($prompt)
for each $option in $menu
if len($option) > $width
$width = len($option)
endif
next
$width = $width + 2
color w+/b
box($y,$x,$y+$height,$x+$width,"single")
at($y,$x+1) substr($prompt,1,$width-2)
$n=0
$option=0
for each $option in $menu
at($y+$n+1,$x+1) $option
$n=$n+1
next
$current = 0
$previous = $current
color b/w+
at($y+$current+1,$x+1) $menu[$current]
at(0,0)
color w/n
do
get $key
if $key = CHR(224) ; Extended Key
get $key
if $key = CHR(80) ; Down Arrow
$current=$current+1
if $current = ubound($menu)+1
$current=0
endif
endif
if $key = CHR(72) ; Up Arrow
$current = $current - 1
if $current = -1
$current = ubound($menu)
endif
endif
color b/w+
at($y+$current+1,$x+1) $menu[$current]
color w+/b
at($y+$previous+1,$x+1) $menu[$previous]
at(0,0)
color w/n
$previous = $current
endif
until $key = CHR(13) or $key = CHR(27) or $key = "Q" ; CR,ESC or Q ?
if $key = CHR(27) or $key = "Q"
$MenuChoice = ""
else
$MenuChoice = $menu[$current]
endif
endfunction



-Shawn

[ 21 October 2001: Message edited by: Shawn ]

Top
#60018 - 2001-10-24 09:06 AM Re: MENU FOR PRINTERS AVAILABLE!!!
Anonymous
Unregistered


Saleem, as much as I like kixtart, my favorite way for printer admining is web based. Depending on the size of the site you support, I think the larger the site, the better this works. I got site plans from the CAD dept, and linked off each building. Clicking on which ever building brings you to another page that shows the floor plans, with the locations of all printers. Then the user can just click on the printer he/she wants to print to. IE does this a little better than netscape, as IE supports "open" on the printer object (which is just a shortcut to the printer, placed on the web server). Netscape, you have to save the shortcut, then double-click it. Furthermore, you can lock down the printing on the print server, if you don't want some joe blow printing of an exec's printer.

Dunno if this will work in your scenario, but just trying to share info....

-Morbid

Top
#60019 - 2001-10-24 11:31 AM Re: MENU FOR PRINTERS AVAILABLE!!!
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
Thanks guys. I would appreciate morbid if you can tell me how to do it exactly..
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
Page 1 of 1 1


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

Who's Online
1 registered (Allen) and 1607 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.119 seconds in which 0.097 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