Page 1 of 1 1
Topic Options
#165743 - 2006-08-10 05:51 PM Newbie Question: Indirect addressing in KIX
HP_Rutschmann Offline
Lurker

Registered: 2006-08-10
Posts: 4
Loc: Basel, Switzerland
Dear all

First of all, thank you for this great tool!

I've checked most of the Torturials, Manuals, and other Documentation, but I wonder whether I could do something similar to this:

Code:

; How many printers are at each site?
$0Printer = ""
$1Printer = "NET1,NET2"
$2Printer = "NET3,NET4,NET5"
$3Printer = "NET6"
;
; Retrieve $NetID here
;
$i = 0
$Printerfound = 0
do
$Pgroup = cstr($i) + "Printer"
if instr($($Pgroup),$NetID) > 0
$Printerfound = 1
else
$i = $i + 1
endif
until ($Printerfound = 1 or $i > 9)
if $Printerfound = 1
for $j = 1 to $i
addprinterconnection("\\"+$NetID+"PS\+"$NetID+"D0"+$j)
next
;


My Problem is now the $($Pgroup) construct which is obviously wrong.

Any ideas and hints are appreciated!

Many thanks and best regards,
HP.


Edited by HP_Rutschmann (2006-08-10 09:57 PM)

Top
#165744 - 2006-08-10 06:16 PM Re: Newbie Question: Indirect addressing in KIX
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
I think you might want to look into using arrays. Then you could do something like...

Code:

for each $printer in $printerArray
if instr($printer,$NetID) and not $printerFound
$printerFound = 1
endif
next


Top
#165745 - 2006-08-10 09:49 PM Re: Newbie Question: Indirect addressing in KIX
HP_Rutschmann Offline
Lurker

Registered: 2006-08-10
Posts: 4
Loc: Basel, Switzerland
Hi Maciep
Thanks for the quick reply!

To be honest, I haven't understood your code (yet) but I keep trying...
...Tomorrow in the office (almost 10pm now)

Basic target is the following loop for addding printers (and thus using the variables $NPrinters defined above).
My ancestor did this with an IF clause for each net which I find - at least - improvable.

best regards from cool Switzerland,
Hanspeter

Top
#165746 - 2006-08-11 12:01 AM Re: Newbie Question: Indirect addressing in KIX
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
I think, because most probably one if statement for one net will be used, per user login on, a select statement can be used.
Top
#165747 - 2006-08-14 09:35 AM Re: Newbie Question: Indirect addressing in KIX
HP_Rutschmann Offline
Lurker

Registered: 2006-08-10
Posts: 4
Loc: Basel, Switzerland
OK, second try: (I can't imagine that nobody did this before)

The task is to add the appropriate number of Printer connections for each site.
Please compare with my code above

Definition of numbers of printers per NetID
Retrieve NetID
Lookup in which Variable is my NetID (AND THIS IS MY PROBLEM!!!)
NumberOfPrinters = f(XPrinter Variables defined above)
for i = i to NumberOfPrinters
addprinterconnection
next

Basically, my question is: "How do I retrieve a variable whose name is stored in another Variable?"

many thanks and best regards,
HP.

Top
#165748 - 2006-08-14 10:15 AM Re: Newbie Question: Indirect addressing in KIX
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I'm still a bit confused about what you are trying to do.

Is it simply:
  • Identify the network
  • Identify the printers on the network
  • Add them


If this is the case you would be better off using a parameter file. The ini file format is ideal for this sort of thing. Each section key is the network, each entry is the printer path. The entry value is not important, but you can use it to identify the default printer for the network.

Your parameter file looks something like this:
Code:
[192.168.0.0]
\\PS1\Printer1=default
\\PS1\Printer2=printer
\\PS1\Printer2=printer
[192.168.1.0]
\\PS2\Printer10=printer
\\PS2\Printer14=default



The additional benefit of using a parameter file is that if you make any typing mistakes it only breaks the section that the mistake is in, it doesn't cause the entire script to fail.


Here is an example of how to dereference a variable:
Code:
$sVar1="This is the target variable"
$sVar2="$$sVar1"
$sVar3="This is the dereference variable"

$vDiscard=Execute("$$sVar3="+$sVar2)
"Dereference of $$sVar2='"+$sVar3+"'"+@CRLF



In this example the variable target is stored in $sVar1 the name is stored in $sVar2. $sVar3 is assigned the value of $sVar1 by using the variable name store in $sVar2.

So it can be done, however it is probably not the most appropriate solution for you.

Top
#165749 - 2006-08-14 10:29 AM Re: Newbie Question: Indirect addressing in KIX
HP_Rutschmann Offline
Lurker

Registered: 2006-08-10
Posts: 4
Loc: Basel, Switzerland
Thanks Richard, I'll check both options.
So far, I obviously missed two tricks:
- the Execute statement and
- the usage of two different string delimiters.

First, I didn't want to use too much files for performance reasons, but - as said before - I'll check this, too

many thanks once more,
HP.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 484 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.057 seconds in which 0.025 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