Page 1 of 1 1
Topic Options
#122305 - 2004-07-07 06:05 PM Reading registry values to validate string.
operez Offline
Getting the hang of it

Registered: 2003-08-08
Posts: 75
I am reading the values for the "HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Excel\microsoft excel" registry sub-key into an array, then sorting the array in ascending order. I want to read the string value of all the OPEN values. I set $valueIndex = 1 and then do:

Code:

For Each $element in $valuearray
If $element = "OPEN" + $ValueIndex
If @ERROR = 0
$stringvalue = ReadValue($regsubkey, $element)
? $stringvalue
$ValueIndex = $ValueIndex + 1
EndIf
EndIf
Next




My first problem is that after I get to OPEN9 it increments to OPEN10 but doesn’t read from value OPEN10 on. OPEN values are listed in ascending order as listed below:

OPEN
OPEN1
OPEN10
OPEN11
OPEN12
OPEN2
OPEN3
OPEN4
OPEN5
OPEN6
OPEN7
OPEN8
OPEN9

Which may be the reason it skips from OPEN10 on. Also I want to read the value of OPEN and if I set $valuearray = 0 or “”, the script doesn’t work.

Once I get past this point, my intensions are to verify string values are valid, remove duplicates or invalid entries and rename the next OPEN value if I have to delete a value. Hope I’m making sense and someone can help.

Top
#122306 - 2004-07-07 08:11 PM Re: Reading registry values to validate string.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I do not understand why you are using a counter at all. If you have collected the "value" names then just use them.

Is @error getting set to a non zero value on the previous read? You have no mechanism to reset it once you get an error.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#122307 - 2004-07-07 08:26 PM Re: Reading registry values to validate string.
operez Offline
Getting the hang of it

Registered: 2003-08-08
Posts: 75
So, how do I distinguish between OPENs, if I don’t tack on a number to it? And, the collection includes several other values other then OPENs. I don’t want to process them. And, how would I then say, OK I had to delete OPEN7 now I need to read the next value to see if there is a OPEN8 and if there is I want to delete OPEN8 and re-create OPEN7 with the string value from OPEN8, and so on, if I don’t tack on a number to it?

Sorry, I’m still new to Kix and don’t get a chance to use it enough to become proficient with it.

Top
#122308 - 2004-07-07 08:41 PM Re: Reading registry values to validate string.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Although I am not new to KiXtart...


I would use associative arrays such that you can keep OPEN3 in the same array element position in a second array. See Hash() Library UDF's for some UDF's that can accomplish this.

A simply approach may be to join the value name and the returned data from the READVALUE into a string separated by a known delimiter like "~".

Or a multi-dimensional array
Dim $Array[12,2]
_________________________
Home page: http://www.kixhelp.com/hb/

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
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.137 seconds in which 0.111 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