Page 2 of 2 <12
Topic Options
#115887 - 2004-03-11 06:10 PM Re: How to refer to a value of a variable as it ...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Yes, I ran this code and the .INI file on my compter. Also, if you want help then you will have to state more than "it doesn't work!". What are the error messages? Is the .INI path correct? KiXtart version? What happens if you run it with DEBUG ON?
_________________________
There are two types of vessels, submarines and targets.

Top
#115888 - 2004-03-11 06:17 PM Re: How to refer to a value of a variable as it ...
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

split statement dosn't work



My guess is he is on a really old version.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#115889 - 2004-03-11 06:41 PM Re: How to refer to a value of a variable as it ...
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
What's with splitting, joining, splitting? why not just:

Code:

$ini='d:\printer.ini'
$printers=split(readprofilestring($ini,'Printers',''),chr(10))
for each $printer in $printers
$users=split(readprofilestring($ini,'Printers',$printer), ',')
if ascan($users,@USERID)+1
? @USERID+' gets printer '+$printer
endif
next


_________________________
Eric

Top
#115890 - 2004-03-11 06:48 PM Re: How to refer to a value of a variable as it ...
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
If his KiX is too old for Split(), then Ascan() would not yeild any better mileage.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#115891 - 2004-03-11 06:52 PM Re: How to refer to a value of a variable as it ...
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
I think split didn't work before because he was trying to split an array.
_________________________
Eric

Top
#115892 - 2004-03-11 06:54 PM Re: How to refer to a value of a variable as it ...
Shadow_van Offline
Fresh Scripter

Registered: 2004-03-10
Posts: 13
Quote:

If his KiX is too old for Split(), then Ascan() would not yeild any better mileage.




Guys,
I started using Kixtart when it was 4.21. It cannot be TOO old, can it?
I check your codes with kixtart 4.22, so let's not consider that point.

Top
#115893 - 2004-03-11 07:01 PM Re: How to refer to a value of a variable as it ...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
A) The code works under Kixtrat v4.22
B) SPLIT-JOIN-SPLIT removes the potential spaces in the list of users and converts it into an array.
C) A "It doesn't work" statement is not helpful, provide details as requested in my previous post.
_________________________
There are two types of vessels, submarines and targets.

Top
#115894 - 2004-03-11 07:12 PM Re: How to refer to a value of a variable as it ...
Shadow_van Offline
Fresh Scripter

Registered: 2004-03-10
Posts: 13
Ok.
There's my c:\printers.ini file:
[Printers]
Printer1=andry,mark,gwen,nick
Printer2=raman,helen,dave
Printer3=wendy,mavis,nicole

I ran the following code:
Break On
?@STARTDIR
?@SCRIPTexe
?@KIX
?@SCRIPTDIR
$ini='c:\printer.ini'
$printers=split(readprofilestring($ini,'Printers',''),chr(10))
for each $printer in $printers
$users=split(readprofilestring($ini,'Printers',$printer), ',')
if ascan($users,@USERID)+1
? @USERID+' gets printer '+$printer

EndIf
Next
Sleep 1000

===========
I used the macros to give you some ideas about kixtart version etc. My USERID is andry

The Output I get from the script above is:

C:\Program Files\PrimalScript\andry\Scripts
KIX32.EXE
4.22
C:\Program Files\PrimalScript\andry\Scripts

In other words, it just prints the macroses and then goes to the SLEEP statemnt. I've traced the script and it appears that $users array is never built properly that's why it cannot find my userid in the $users array.

Thanks for spending your time on my issue.





Top
#115895 - 2004-03-11 07:15 PM Re: How to refer to a value of a variable as it ...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
That's why your .INI file is called C:\PRINTERS.INI and in the script you call C:\PRINTER.INI.
_________________________
There are two types of vessels, submarines and targets.

Top
#115896 - 2004-03-11 07:27 PM Re: How to refer to a value of a variable as it ...
Shadow_van Offline
Fresh Scripter

Registered: 2004-03-10
Posts: 13
Quote:

That's why your .INI file is called C:\PRINTERS.INI and in the script you call C:\PRINTER.INI.




It works now!

DAMN!
I ain't that stupid, I swear!
BUT I DID THAT MISTAKE!
Thanks a lot for your help!

One more time appreciate your help!

Top
Page 2 of 2 <12


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

Who's Online
0 registered and 159 anonymous users online.
Newest Members
emnipetro, Hirze, thequeen, ameliaryan, shalomsalami
17641 Registered Users

Generated in 0.034 seconds in which 0.012 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org