Page 1 of 1 1
Topic Options
#201196 - 2010-12-17 03:17 PM Reading File - Conditional Options
KIXKicks Offline
Starting to like KiXtart

Registered: 2002-07-26
Posts: 177
Loc: Vancouver, WA
Can I read a file when conditions on it? I want it to read the file and return the data if the Case statement is true. It works if it is in the main kix file but the list is getting rather large and I was hoping to separate the code from the list.

Such as (code is best guess)

 Code:
TESTSCRIPT.KIX
$LICENSEDUSER = ReadProfileString('C:\NETWORK\SOFTWARE.INI', 'DS_CATIA_V5_19', $LICENSEVALID)

SOFTWARE.INI File
[DS_CATIA_V5_19]
Select
   Case $USERNAME = "AGarcia" And $SERIALNO = "1234567"		$DRIVE = "D:"	$LICENSEVALID = "YES"
EndSelect

Top
#201197 - 2010-12-17 03:24 PM Re: Reading File - Conditional Options [Re: KIXKicks]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
Are you saying the select statement is in your ini file? If so, you just broke the ini standard. You need to read a value from your ini file and then do the logic in your kix script.

Sorry if I misunderstood.

Top
#201198 - 2010-12-17 03:48 PM Re: Reading File - Conditional Options [Re: BradV]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
[ scratch head ]You can't put code in an ini file and expect it to run like that.

Outline your process flow, not your code, so we can figure out the best way to help.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#201199 - 2010-12-17 03:52 PM Re: Reading File - Conditional Options [Re: Glenn Barnas]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
[/scratch head]

\:\)

Top
#201200 - 2010-12-17 03:57 PM Re: Reading File - Conditional Options [Re: KIXKicks]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
After further head scratching, I'm guessing you know the local license # and username and want to determine if they match.. if so, set some other values. If so, then here's some ideas:
 Code:
$SerialNo = '123' ; read from registry, maybe?
; get the user associated to this serial number
$RegUser = ReadProfileString('software.ini', $SerialNo, 'RegisteredUser')

; See if they match
If $RegUser = @USERID
  $Drive = ReadProfileString('software.ini', $SerialNo, 'Drive')
  $LicenseValid = 'Yes'
EndIf
The ini file would be something like:
 Code:
; Each section is a serial number
[123]
RegisteredUser=AGarcia
Drive=D:
Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#201201 - 2010-12-17 03:58 PM Re: Reading File - Conditional Options [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Thanks, Allen.. bald spot was getting bigger! \:D
_________________________
Actually I am a Rocket Scientist! \:D

Top
#201208 - 2010-12-17 07:16 PM Re: Reading File - Conditional Options [Re: Glenn Barnas]
KIXKicks Offline
Starting to like KiXtart

Registered: 2002-07-26
Posts: 177
Loc: Vancouver, WA
Yes, I kinda realized that the ini file would have to be changed to what you have list there...it is actually more work than just to keep it in the KIX file...

Thanks.

Top
#201228 - 2010-12-18 01:43 PM Re: Reading File - Conditional Options [Re: KIXKicks]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Might be, but every time you change code to alter data, you risk the code not working. External data is always the better option.

Anytime that I need to work with variable data, I start by building the data file - either an INI or CSV file. Excel, too, since I can dump it to CSV easily. With FileIO() and CSV() I can read the entire file with one line and enumerate it, converting the CSV records to arrays.

Only after I have the data laid out do I start writing the script to use the data and then process it. I can alter the data anytime and never touch the script again.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


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

Who's Online
0 registered and 811 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

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