Page 1 of 1 1
Topic Options
#47960 - 1999-07-16 03:05 AM Please look at my script!
vvo Offline
Fresh Scripter

Registered: 1999-07-16
Posts: 6
Loc: Arnhem, Gld, Netherlands
I have a main logon script but having difficulties with a particular part of it.
The problem it keeps display the '0' output to the screen. Although I'm using variables to put the results in ...

Here's the script; main purpose is to read printers from a central printer file and connect them to the local workstation.

PS. Any comment is welcome, I'm not a programmer, just tried to use some logical thinking. Any other way of doing the same job which is faster and certainly better is welcome.


; rem ****************************************************************
; rem * Function : AssignNetworkPrinters()
; rem * Developer : J. Vorsterman van Oijen (vvo@ft.han.nl)
; rem * Purpose : Assign various network printers.
; rem * Gets info from 3 flat-file databases.
; rem *
; rem * Revision : July 14, 1999 - v1.0
; rem ****************************************************************

; rem * Local variables used in this function

; rem * Which FileServer do we need to attach to?
IF (@LDOMAIN = "FT-P")
$Server1 = "\\FT-P3"
ELSE
$Server1 = "\\FT-A2"
ENDIF

$Dombo = OPEN ( 8, $PrintFileOut, 5) ; rem * Where to write the output
IF (@ERROR <> 0)
SENDMESSAGE ("$AdminEmail", "Kan $PrintFileOut niet aanmaken. Onmiddelijk controleren!")
$Dummy = WRITELINE (10, "$PrintFileOut kon niet gecreerd worden door @USERID om @TIME op @WKSTA." + CHR(13) + CHR(10))
$EmailMessage = "$PrintFileOut kon niet geopend worden door @USERID om @TIME op @WKSTA."
GOSUB SendAdminMail
$Status = "Error"
MESSAGEBOX ("$PrintFileOut kan niet aangemaakt worden. De SYSADMIN is gewaarschuwd!","Notice",48)
RETURN
ENDIF

$Result = OPEN ( 3, $PrintFileIn, 2) ; rem * Read central printer definitions

IF ($Result <> 0)
SENDMESSAGE ("$AdminEmail", "Kan $PrintFileIn niet openen voor lezen. Onmiddelijk controleren!")
$Dummy = WRITELINE (10, "$PrintFileIn kon niet geopend worden door @USERID om @TIME op @WKSTA." + CHR(13) + CHR(10))
$EmailMessage = "$PrintFileIn kon niet geopend worden door @USERID om @TIME op @WKSTA."
GOSUB SendAdminMail
$Status = "Error"
MESSAGEBOX ("$Het Centrale Printer Definitie (CPD) bestand kan niet geopend worden. De SYSADMIN is gewaarschuwd!","Notice",48)
CLOSE (3) ; rem * $PrintFileIn is being closed
CLOSE (8) ; rem * $PrintFileOut is being closed
RETURN
ELSE

$Dummy = WRITELINE (10, "$PrintFileIn geopend voor lezen ... door @USERID om @TIME." + CHR(13) + CHR(10))
$x = READLINE (3)

; rem If allright just go in the while..loop
WHILE @ERROR = 0
; rem MAC address
$a = SUBSTR ($x, 1,13)
; rem Remove all spaces
$a = LTRIM (RTRIM($a))

IF $a = @ADDRESS
; * rem PCID must be unique
$workstat = SUBSTR ($x,15, 6)
$workstat = LTRIM (RTRIM($workstat))

; * rem Which location?
$b = SUBSTR ($x,23, 6)
$b = LTRIM (RTRIM($b))

; * rem Read 1st check field
$common1 = SUBSTR ($x,30, 1)
$common1 = LTRIM (RTRIM($common1))

; * rem Read 2nd check field
$common2 = SUBSTR ($x,32, 1)
$common2 = LTRIM (RTRIM($common2))
ENDIF
$x = READLINE (3)
LOOP
CLOSE (3) ; rem * $PrintFileIn is being closed

; rem * If $common1 = 's' then the PC gets default networkprinters (no local printers)
IF ($common1 = 's')
$result1 = OPEN (4, $PrintFileRoom, 2)
IF ($result1 = 0)
$y = READLINE(4)
$lok = SUBSTR ($y, 1, 5)
$lok = LTRIM (RTRIM($lok))

WHILE ($lok <> $b)
$y = READLINE (4)
$lok = SUBSTR ($y, 1, 5)
$lok = LTRIM (RTRIM($lok))
LOOP

$control2 = SUBSTR ($y, 8, 1)
$control2 = LTRIM (RTRIM($control2))

$pr_1 = SUBSTR ($y,10,23) ; rem * Default printer
LTRIM (RTRIM($pr_1)
IF SETDEFAULTPRINTER ("$Server1\$pr_1") = 0
$pr1 = "$Server1\$pr_1 (aanwezig)" ELSE $pr1 = "$Server1\$pr_1 niet aangesloten!" ENDIF
$pr_2 = SUBSTR ($y,34,23) ; rem * 2e printer
LTRIM (RTRIM($pr_2)
IF ADDPRINTERCONNECTION ("$Server1\$pr_2") = 0
$pr2 = "$Server1\$pr_2 (aanwezig)" ELSE $pr2 = "$Server1\$pr_2 niet aangesloten!" ENDIF
$pr_3 = SUBSTR ($y,58,23) ; rem * 3e printer
LTRIM (RTRIM($pr_3)
IF ADDPRINTERCONNECTION ("$Server1\$pr_3") = 0
$pr3 = "$Server1\$pr_3 (aanwezig)" ELSE $pr3 = "$Server1\$pr_3 niet aangesloten!" ENDIF
; rem * Write Printers to local text file, just for checking which printers are assigned
$Dombo = WRITELINE (8, "$pr_1,$pr_2,$pr_3" + CHR(13) + CHR(10))
$Dummy = WRITELINE (10, "Printers: $pr_1,$pr_2,$pr_3" + CHR(13) + CHR(10))
$Status = CHR(251) + " OK"

WHILE ($control2 <> $common2)
$y = READLINE (4)
$lok = SUBSTR ($y, 1, 5)
$lok = LTRIM (RTRIM($lok))

$control2 = SUBSTR ($y, 8, 1)
$control2 = LTRIM (RTRIM($control2))

$pr_1 = SUBSTR ($y,10,23) ; rem * Default printer
LTRIM (RTRIM($pr_1)
IF SETDEFAULTPRINTER ("$Server1\$pr_1") = 0
$pr1 = "$Server1\$pr_1 (aanwezig)" ELSE $pr1 = "$Server1\$pr_1 niet aangesloten!" ENDIF
$pr_2 = SUBSTR ($y,34,23) ; rem * 2e printer
LTRIM (RTRIM($pr_2)
IF ADDPRINTERCONNECTION ("$Server1\$pr_2") = 0
$pr2 = "$Server1\$pr_2 (aanwezig)" ELSE $pr2 = "$Server1\$pr_2 niet aangesloten!" ENDIF
$pr_3 = SUBSTR ($y,58,23) ; rem * 3e printer
LTRIM (RTRIM($pr_3)
IF ADDPRINTERCONNECTION ("$Server1\$pr_3") = 0
$pr3 = "$Server1\$pr_3 (aanwezig)" ELSE $pr3 = "$Server1\$pr_3 niet aangesloten!" ENDIF
$Dombo = WRITELINE (8, "$pr_1,$pr_2,$pr_3" + CHR(13) + CHR(10)) ; rem * Write Printers to local text file
$Dummy = WRITELINE (10, "Printers: $pr_1,$pr_2,$pr_3" + CHR(13) + CHR(10))
$Status = CHR(251) + " OK"
LOOP
ENDIF
CLOSE (4) ; rem * $PrintFileRoom is being closed
ELSE
$result2 = OPEN (5, $PrintFilePCID, 2)
IF ($result2 = 0)
$z = READLINE (5)
WHILE (@ERROR = 0)
$pcnr = SUBSTR ($z, 1, 7)
$pcnr = LTRIM (RTRIM($pcnr))
; rem * $workstat is already filled from $PrintFileIn
IF $pcnr = $workstat
; rem * Just read all of the printers
$pr_1 = SUBSTR ($z, 9,23)
$pr_1 = LTRIM (RTRIM($pr_1))
IF SETDEFAULTPRINTER ("$Server1\$pr_1") = 0
$pr1 = "$Server1\$pr_1 (aanwezig)" ELSE $pr1 = "$Server1\$pr_1 niet aangesloten!" ENDIF
$pr_2 = SUBSTR ($z,33,23)
$pr_2 = LTRIM (RTRIM($pr_2))
IF ADDPRINTERCONNECTION ("$Server1\$pr_2") = 0
$pr2 = "$Server1\$pr_2 (aanwezig)" ELSE $pr2 = "$Server1\$pr_2 niet aangesloten!" ENDIF
$pr_3 = SUBSTR ($z,57,23)
$pr_3 = LTRIM (RTRIM($pr_3))
IF ADDPRINTERCONNECTION ("$Server1\$pr_3") = 0
$pr3 = "$Server1\$pr_3 (aanwezig)" ELSE $pr3 = "$Server1\$pr_3 niet aangesloten!" ENDIF
$Dombo = WRITELINE (8, "$pr_1,$pr_2,$pr_3" + CHR(13) + CHR(10)) ; rem * Write Printers to local text file
$Dummy = WRITELINE (10, "Printers: $pr_1,$pr_2,$pr_3" + CHR(13) + CHR(10))
$Status = CHR(251) + " OK"
ENDIF
$z = READLINE (5)
LOOP
ENDIF
CLOSE (5) ; rem * $PrintFilePCID is being closed
ENDIF
CLOSE (8) ; rem * $PrintFileOut is being closed
ENDIF

RETURN

Thanks!

------------------

Johan Vorsterman van Oijen (Netherlands)

_________________________
Johan Vorsterman van Oijen (Netherlands)

Top
#47961 - 1999-07-16 04:15 AM Re: Please look at my script!
Anonymous
Unregistered


The '0' come from the sendmassage commands, you can suppress these like this:
$ret = sendmessage(....)
Also the MessageBox function return a '0' so to suppress these the command looks like this:
$ret = messagebox(...)

------------------
Lon Geefshuysen,
www.xs4all.nl/~longeef/NT/KiXtart
lon_geefshuysen@essentium.com


Top
#47962 - 1999-07-16 04:19 AM Re: Please look at my script!
vvo Offline
Fresh Scripter

Registered: 1999-07-16
Posts: 6
Loc: Arnhem, Gld, Netherlands
Lon,
Thanks, bedankt, danke :-)

I'll change the code.

------------------

Johan Vorsterman van Oijen (Netherlands)

_________________________
Johan Vorsterman van Oijen (Netherlands)

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
0 registered and 1927 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.054 seconds in which 0.027 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