#70950 - 2002-10-22 12:25 AM
HELP: Canīt get BREAK ON to function
|
redniels
Fresh Scripter
Registered: 2002-10-21
Posts: 19
Loc: Netherlands
|
Hello,
Iīm using kixstart for a while now, and while I canīt call myself "good" at it, Iīm not a complete newbie..
I have 2 scripts which have to use BREAK ON, thus make the user[s] able to close the script before it exits.. ever since weīve gone from kix 3.62 to later versions [4.02 etc] I canīt get BREAK ON to work..Users just canīt exit from the script and itīs a pain. Pls tell me what I do wrong because I canīt see it..
Included here is a copy of a script I wrote to make it easier for my [l]users to connect to a printer. For many of them browsing the network/server for a printer is a daunting task which was just to complicated.. This script allows them to just enter the printername & hit enter..
anyway: with kix version =< 3.62 the users could exit from it, but now...no more. worse still, even after the script has completed the window is not closeable, except afcourse when they logoff/logon..
the script output is in dutch, but that shouldnīt be a big problem...
the script uses a HIDDEN$ [doh] share on the printserver on which everyone has READ rights to check if a server is online..
the script calls a batch file d.bat which is very simple it is just the following 2 lines:
@ECHO OFF START %PRINTERVAR%
the printerad.kix file: [iīve replaced company, groups, department & servernames with fictional ones, hope you understand why..] also I had to replace normal parenthesis with [ and ]to be able to post it here...strange..or not?
;addprinter script, dit script maakt op aanwijzingen van een gebruiker een printer aan ;dit is onder Windows95 en Windows NT4 getest, ;werkt voor 99,9% zeker ook onder Windows2000, Windows XP, Windows 98 en Windows ME ; variabelen in gebruik: ;$SERVERNAAM ;$PRINTERNAAM ;$ANSWER1 ;LABELS in gebruik ;SERVERSELECT ;PRINTERSELECT ;PRINTERDIALOOG1 ;GO1 ; v2.0 2 JAN 2001 [C]NPK [BREAK=ON ERBIJ]
BREAK ON color y+/b cls flushkb :SERVERSELECT ? "==================================================================" ? "COMPANYNAME, DEPARTMENT 2001" ? "een moment alstublieft..." ? "=================================================================="
if INGROUP ["BO"] GOSUB "SRV1" endif if INGROUP ["GO"] GOSUB "SRV1" endif if INGROUP ["RD"] GOSUB "SRV1" endif if INGROUP ["PU"] GOSUB "SRV1" endif if INGROUP ["CS"] GOSUB "SRV1" endif if INGROUP ["BW"] GOSUB "SRV1" endif if INGROUP ["BD"] GOSUB "SRV2" endif if INGROUP ["BR"] GOSUB "SRV2" endif if INGROUP ["CU"] GOSUB "SRV2" endif if INGROUP ["EX"] GOSUB "SRV2" endif
if $servernaam <> "SERVER2" if $servernaam <> "SERVER1" CLS ? "==================================================================" ? "Dit script kan GEEN Printserver vinden! Misschien is er iets mis " ? "met een van de servers of met het netwerk. Neem svp contact op met" ? "de COMPANY Klantenbalie, telefoonnummer xxxxx" ? "==================================================================" sleep 10 goto UIT endif endif
color w+/b ? " De beschikbare server in deze sessie is $SERVERNAAM geworden...." color y+/b
? "==================================================================" cls GOSUB PRINTERSELECT GOSUB GO1 ? "dit programma is klaar, Windows printerinstallatie is gestart..." ? "=================================================================="
:UIT EXIT
:SRV1 if exist ["\\SERVER1\HIDDEN$\CHECK.TXT"] $SERVERNAAM = "SERVER1" ELSE $SERVERNAAM = "SERVER2" ENDIF RETURN
:SRV2 if exist ["\\SERVER2\HIDDEN$\CHECK.TXT"] $SERVERNAAM = "SERVER2" ELSE $SERVERNAAM = "SERVER1" ENDIF RETURN
:PRINTERSELECT ? "==================================================================" ? "toets de Printernaam in, dit staat op iedere printer op een" ? "sticker, en begint altijd met PR0nummer [voorbeeld: PR0511]" ? "als U de juiste printer heeft ingevuld, druk dan op ENTER" color W+/b ? "LET OP: EERSTE cijfer is een NUL geen letter O!" color y+/b ? "=================================================================="
color w+/b ? "-->" color r+/b GETS $PRINTERNAAM color y+/b GOSUB PRINTERDIALOOG1 RETURN
:PRINTERDIALOOG1 cls ? "==================================================================" ? "De gekozen PRINTER naam is" color r+/b ? "$PRINTERNAAM" color y+/b ? "is dit juist?" ? "ENTER doorgaan, toets N[ee]om opnieuw een printerselectie te maken" ? "==================================================================" color w+/b ? "-->" color y+/b GET $ANSWER1 IF $ANSWER1 = "n" OR $ANSWER1 = "N" GOSUB PRINTERSELECT ENDIF RETURN
:GO1 SETL "PRINTERVAR=\\$SERVERNAAM\$PRINTERNAAM" RUN "D.BAT" RETURN
|
|
Top
|
|
|
|
#70951 - 2002-10-22 12:52 AM
Re: HELP: Canīt get BREAK ON to function
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
quess this is more fitting forum for your post...
first (before getting to the problems) I quess some syntax cleaning could be usable.
anyway, I haven't got break on working either. and nowadays, break off works neither!
what comes to the script not ending, you could tell us, on what os. I quess it's on win9x, right?
also, using goto is not good habit. neither specifying exit without error code as it then reads the next stuff for errorcode. about your brackets, if it works like: if ingroup ["some"]
ok, but correct way would be: if ingroup("some")
anyway, I'm not trying now to fix your code here but to make it easier for others to read it too. so: code:
BREAK ON color y+/b cls flushkb
;SERVERSELECT ? "==================================================================" ? "COMPANYNAME, DEPARTMENT 2001" ? "een moment alstublieft..." ? "=================================================================="
select case INGROUP("BO") GOSUB "SRV1" case INGROUP("GO") GOSUB "SRV1" case INGROUP("RD") GOSUB "SRV1" case INGROUP("PU") GOSUB "SRV1" case INGROUP("CS") GOSUB "SRV1" case INGROUP("BW") GOSUB "SRV1" case INGROUP("BD") GOSUB "SRV2" case INGROUP("BR") GOSUB "SRV2" case INGROUP("CU") GOSUB "SRV2" case INGROUP("EX") GOSUB "SRV2" case 1 CLS ? "==================================================================" ? "Dit script kan GEEN Printserver vinden! Misschien is er iets mis " ? "met een van de servers of met het netwerk. Neem svp contact op met" ? "de COMPANY Klantenbalie, telefoonnummer xxxxx" ? "==================================================================" sleep 10 exit 1 endselect
color w+/b ? " De beschikbare server in deze sessie is $SERVERNAAM geworden...." color y+/b
? "==================================================================" cls GOSUB PRINTERSELECT GOSUB GO1 ? "dit programma is klaar, Windows printerinstallatie is gestart..." ? "==================================================================" exit 0
:SRV1 if exist("\\SERVER1\HIDDEN$\CHECK.TXT") $SERVERNAAM = "SERVER1" ELSE $SERVERNAAM = "SERVER2" ENDIF RETURN
:SRV2 if exist ["\\SERVER2\HIDDEN$\CHECK.TXT"] $SERVERNAAM = "SERVER2" ELSE $SERVERNAAM = "SERVER1" ENDIF RETURN
:PRINTERSELECT ? "==================================================================" ? "toets de Printernaam in, dit staat op iedere printer op een" ? "sticker, en begint altijd met PR0nummer [voorbeeld: PR0511]" ? "als U de juiste printer heeft ingevuld, druk dan op ENTER" color W+/b ? "LET OP: EERSTE cijfer is een NUL geen letter O!" color y+/b ? "=================================================================="
color w+/b ? "-->" color r+/b GETS $PRINTERNAAM color y+/b GOSUB PRINTERDIALOOG1 RETURN
:PRINTERDIALOOG1 cls ? "==================================================================" ? "De gekozen PRINTER naam is" color r+/b ? "$PRINTERNAAM" color y+/b ? "is dit juist?" ? "ENTER doorgaan, toets N[ee]om opnieuw een printerselectie te maken" ? "==================================================================" color w+/b ? "-->" color y+/b GET $ANSWER1 IF $ANSWER1 = "n" GOSUB PRINTERSELECT ENDIF RETURN
:GO1 SETL "PRINTERVAR=\\$SERVERNAAM\$PRINTERNAAM" RUN "D.BAT" RETURN
but it still has a lot of sub scripts... quess you have worked with bats a lot
cheers.
_________________________
!download KiXnet
|
|
Top
|
|
|
|
#70953 - 2002-10-21 11:48 PM
Re: HELP: Canīt get BREAK ON to function
|
redniels
Fresh Scripter
Registered: 2002-10-21
Posts: 19
Loc: Netherlands
|
first off, thanks guys for the quick response, and yes, this is a more suitable place for this question..
now, to answer your questions: 1-which Windows: We're using W9x, NT4, W2K, WXP.. all of them have this problem (break on not functioning) and indeed after completing the script only w9x can't close the box..
2-Goto Sucks. You're right. In the first kix "lesson" I got from an old (if you're reading this: Hi, bart!)collegue of mine, he told me: "Goto sucks. period. it's spaghetti. And I don't like spaghetti.etc etc(continue rant about goto) :-) I know I should use gosub, but old habits die hard, and yes, indeed, I'm still a batch guy.
3-fix my code Please do! :-) I know I'm not a clean or gifted script writer, that's the reason I became a sysadmin, (users don't look at it and still think I'm great) :-) (joke!) no, serious, I've never took the time to clean it up, (too busy) it just worked & I never again looked at it..till a few months ago when we started using 4.02.
btw: If you think this one is messy, i've got another one for you if you're interested..Even I can see that that one is a real load of... ;-) but hey, it works! so again, I never took the time to change it..maybe I should..
4- I'm not that comfortable about distributing a hacked .dll to all our W9X workstations... and even then, We still have a problem on NT4/W2K/WXP. right? If I understand you guys correctly it's a "bug" in kix, since version 4.02? or do I completely miss the bus here..?
maybe I should just call kix32 V3.62 for this script as a quick & dirty solution...
and lonkero, thanks for the cleanup..
|
|
Top
|
|
|
|
#70957 - 2002-10-22 05:23 PM
Re: HELP: Canīt get BREAK ON to function
|
redniels
Fresh Scripter
Registered: 2002-10-21
Posts: 19
Loc: Netherlands
|
And indeed, you all were right..
the original script(s) needed some (understatement) rewriting and after that the spaghetti programming was gone and it worked like before..(break on that is) Itīs still too large, and Iīm sure that thereīs a better way to check if a server is online, but thatīs a "to do" for another time.
The problem was completely eliminated after I used the SHELL command instead of RUN in the script..strange...?
the new code, which now functions, is found below..
code:
BREAK ON color y+/b cls flushkb ? "==================================================================" ? "COMPANY, DEPARTMENT 2001" ? "een moment alstublieft..." ? "=================================================================="
SELECT CASE INGROUP("BO") $servernaam="SERVER1" CASE INGROUP("GO") $servernaam="SERVER1" CASE INGROUP("RD") $servernaam="SERVER1" CASE INGROUP("PU") $servernaam="SERVER1" CASE INGROUP("CS") $servernaam="SERVER1" CASE INGROUP("BW") $servernaam="SERVER1" CASE INGROUP("BD") $servernaam="SERVER2" CASE INGROUP("BR") $servernaam="SERVER2" CASE INGROUP("CU") $servernaam="SERVER2" CASE INGROUP("EX") $servernaam="SERVER2" CASE 1 $STATUS=VOUT ENDSELECT
:PRINTERSELECT
if exist ("\\$servernaam\HIDDEN$\CHECK.TXT") ? "==================================================================" ? "toets de Printernaam in, dit staat op iedere printer op een" ? "sticker, en begint altijd met PR0nummer (voorbeeld: PR0511)" ? "als u de juiste printer heeft ingevuld, druk dan op ENTER" color W+/b ? "LET OP: EERSTE cijfer is een NUL geen letter O!" color y+/b ? "==================================================================" color w+/b ? "-->" color r+/b GETS $PRINTERNAAM color y+/b cls ? "==================================================================" ? "De gekozen PRINTER naam is" color r+/b ? "$PRINTERNAAM via $servernaam" color y+/b ? "is dit juist?" ? "ENTER doorgaan, toets N(ee)om opnieuw een printerselectie te maken" ? "==================================================================" color w+/b ? "-->" color y+/b GET $ANSWER1 IF $ANSWER1 = "n" GOSUB PRINTERSELECT ENDIF SETL "PRINTERVAR=\\$SERVERNAAM\$PRINTERNAAM" SHELL "%WINDIR%\DWP\D.BAT" $STATUS=OK
RETURN RETURN ELSE IF $SERVERNAAM="SERVER2" IF EXIST ("\\SERVER1\HIDDEN$\CHECK.TXT") $servernaam="SERVER1" $STATUS=REDO ELSE $STATUS=VOUT ENDIF ENDIF IF $SERVERNAAM="SERVER1" AND $STATUS <> "REDO" IF EXIST ("\\SERVER2\HIDDEN$\CHECK.TXT") $SERVERNAAM="SERVER2" $STATUS=REDO ELSE $STATUS=VOUT ENDIF ENDIF ENDIF
if $STATUS=VOUT CLS ? "==================================================================" ? "Dit script kan GEEN Printserver vinden! Misschien is er iets mis " ? "met een van de servers of met het netwerk." ? "Het kan ook zijn dat voor u geen hoofdgroep is gezet.(PU, BD, etc)" ? "Neem contact op met de DEPARTMENT Klantenbalie, telefoonnummer xxx xx xx" ? "==================================================================" sleep 10 endif
IF $STATUS = "REDO" GOSUB PRINTERSELECT ENDIF
? "status was "$status" EXIT 0
All in all: problem solved, once again thanks all for putting me back on track..
|
|
Top
|
|
|
|
#70961 - 2002-10-25 11:10 AM
Re: HELP: Canīt get BREAK ON to function
|
redniels
Fresh Scripter
Registered: 2002-10-21
Posts: 19
Loc: Netherlands
|
quote:
that is still the bug of it.
it won't work if you have endless loop eating up all processor power. and that is only reason why I would need it.
it needs time to be raisen and if the other script is eating lot's of processor time, it's left to handled later
Iīm beginning to feel like a real user. now I know what they go through everyday.
maybe I should just use %comspec% and remove the whole batch thingy...
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1471 anonymous users online.
|
|
|