I'm new to this forum (and Kix scripting itself!) so Im sorry if I put this in the wrong area.
I work for a computer company that does work for a local high school. The school has one printer per room, and they wish for the login script to pick the printer that is in the room with any given machine, and make it the default. A section of the script I have to do this is as follows:
code:
IF @WKSTA = "D1-PC01" OR @WKSTA = "D1-PC02" OR @WKSTA = "D1-PC03" OR @WKSTA = "D1-PC03" OR @WKSTA = "D1-PC04" OR @WKSTA = "D1-PC05" OR @WKSTA = "D1-PC06" OR @WKSTA = "D1-PC07" OR @WKSTA = "D1-PC08" OR @WKSTA = "D1-PC09" OR @WKSTA = "D1-PC10" OR @WKSTA = "D1-PC11" OR @WKSTA = "D1-PC12" OR @WKSTA = "D1-PC13" OR @WKSTA = "D1-PC14" OR @WKSTA = "D1-PC15" OR @WKSTA = "D1-PC16" OR @WKSTA = "D1-PC17" OR @WKSTA = "D1-PC18" OR @WKSTA = "D1-PC19" OR @WKSTA = "D1-PC20" OR @WKSTA = "LEAT 30"
This is just for one classroom, and whilst it does work, its slow as hell! There are about 200 machine names in total and 80% of the time they start with (as in this case) "D1-(machine number)". In order to speed up script execution, is there any way of using a wildcard after the 'D1-', and setting the printer from that IF? This way I would only have to go thru 20 lines of code as opposed to 200. I believe this would speed things up...is this likely to be the case, or am I barking up the wrong tree?
Hope you understand what Im getting at, and thanks for reading
will this exit the IF statement only, or the whole script?
In response to the 'what is dfltpntr.kix?', I really dont know. We are new to the school and are trying to make things work a little faster for the mean time. Im sure there will be more slim lining going on in time!
Apparently the last script was very long winded because for a time they were running mainly Win 98 machines, and they now use almost exclusively Win2k Pro. If you are interested, I've changed the code so it reads thus
code:
IF SUBSTR(@WKSTA,1,2) = "D1" OR @WKSTA = "LEAT 30"
Would be curious to know, if it works, how much (if any) boost in login speed you get. If you get the chance, please lets us know one way or the other ?
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Save yourself some grief in the future and get used to providing a value with "EXIT".
Not only is it good practice to provide a status when EXITing (or QUITing), but some code will break if there is no value.
Use "Exit 0" for a success and "Exit n" where "n" is a posotive integer for a failure. Where possible use a valid DOS/Windows error number for the exit code which has a meaning close to the actual problem, as this will allow the @SERROR macro to report something meaningful.
Howard BullockHoward Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Still don't know why you has the "EXIT" at the end of the IF statement. This should make any appreciable difference in execution time once you have properly constructed IF or Select...CASE...EndSelect constructs.
hmmm, i kinda got into the habit of doing EXIT 1 meaning EXIT [TRUE] as oppposed to EXIT 0 meaning EXIT [FALSE]. Think Richard is right though, EXIT 0 would probably be best pratice and is more DOS like ...
-Shawn
[ 13. June 2003, 14:07: Message edited by: Shawn ]