Arno.v.Rijn
(Lurker)
2003-10-08 02:28 PM
Printer Assignment per Workstation

Hey,

I have the following problem:
I want to assign a printer to a workstation when the first 3 digits are valid to the one entered

Example:
Workstation B01W12543 must get printer B01P10126

When i logon the printer is not present.
When i assign a printer per group (if ingroup) everything works fine.

IF (SUBSTR(@WKSTA,1,3)="B01"then
Addprinterconnection("\\edu01\B01P10126")
SETDEFAULTPRINTER("B01P10126")

Who can help me?

Already thnx

Arno


Kdyer
(KiX Supporter)
2003-10-08 02:32 PM
Re: Printer Assignment per Workstation

Arno,

Welcome to the board!

For this example, why not use LEFT instead?

Also, there is no need to use "THEN" either. [Wink] In fact, it will indeed fail on you.

For example -
code:
IF LEFT(@WKSTA,3)="B01"
;do stuff
ENDIF

It might even be better (depending on how many printers) to do a SELECT..CASE..ENDSELECT statement.

How many printers are you working with?

Kent

[ 08. October 2003, 14:34: Message edited by: kdyer ]


Arno.v.Rijn
(Lurker)
2003-10-08 02:42 PM
Re: Printer Assignment per Workstation

Now this day i work with 4 printers. In a few months this number is 20+

I gonna test it right now THNX!


Kdyer
(KiX Supporter)
2003-10-08 02:47 PM
Re: Printer Assignment per Workstation

Look into the use of SELECT..CASE..ENDSELECT

This will serve you well with this as you are looking for the first true condition based on a workstation name.

When you get to the 20, you may want to take it up a notch and do this on an array. Look into the use of "SPLIT".

Kent


Sealeopard
(KiX Master)
2003-10-08 06:02 PM
Re: Printer Assignment per Workstation

Or even create a .INI file with an appropriate structure and utilizing READPROFILESTRING. See e.g. UnmapPrinters() - Removes mapped printers not listed in an .INI file