Page 1 of 1 1
Topic Options
#201125 - 2010-12-10 09:15 PM READVALUE function -- Weird results
JNK Offline
Fresh Scripter

Registered: 2006-04-11
Posts: 33
Loc: USA
First, my environment:

Kix: 4.61
O/S: Windows 7 Enterprise, 32-bit

While working on a mainteance script, I stumbled upon a weird issue that really has me head-scratching. I am having some weird (read: different) results with the READVALUE function, where I get one value if I direct output to a log file and a different value if I output to the screen.

 Code:
   ; ===== Open the log file =====
   $log = split (@scriptname,".")
   $logfile = @scriptdir + "\" + $log[0] + ".log"
   $x = redirectoutput ($logfile,1)
   " ========== @scriptname =========="?
   
   ; ===== Read value from registry =====
   $regkey = "hkcu\software\microsoft\windows\currentversion\internet settings\connections"
   $regentry = "defaultconnectionsettings"
   $regdata = readvalue ($regkey,$regentry)
   $regdata ?
   
   ; ===== The bitter end =====
   " ========== @scriptname =========="?
   $x = redirectoutput ("")
   
   exit 0


If I open the log file (in the same folder as my .kix script), I see a value of ...

4600000022010000090000000e00000032382e38362e36332e33323a3830070000002a2e6c6
f63616c000000000500000000000000a0b9e676a198cb010000000000000000000000000200
000002000000ac10011f0000000000000000000000000000000000000000000000001700000
0000000000000000000000000000000000000000100000000000000001c0000000000000000
000000000000000000000000000000000000000000000017000000000000000000000000000
0000000ffffac10011f00000000000000001700000000000000000000000000000000000000
00000001000000000000000099000099302f0000e0614200d8e741000000000004000000000
00000010000000300000000000000000000000c8d4200feffffff0c00000002000000010042
000000000080000000000000000000000000000000000000000000000000000000

This value is correct and matches the value I see when viewing the registry in Regedit.

Now, if I use the same code and get rid of the log file, the output goes to the screen.


 Code:
   ; ===== Read value from registry =====
   $regkey = "hkcu\software\microsoft\windows\currentversion\internet settings\connections"
   $regentry = "defaultconnectionsettings"
   $regdata = readvalue ($regkey,$regentry)
   $regdata ?
   
   sleep 20 ; so I have time to copy the text from the window ...
   
   exit 0



Instead of the value I saw before, I get ... 0000000000800000000000000000000000000000000000000000000000000000004200feffffff0c00000002000000010042 instead.

I can duplicate the issue on XP Pro and Windows 7 Enterprise, 64-bit.

Kixtart 4.53, 4.60, 4.61 BETA and 4.61 all yield the same result.

Any ideas?


Edited by Glenn Barnas (2010-12-10 10:07 PM)
Edit Reason: broke long line

Top
#201127 - 2010-12-10 10:08 PM Re: READVALUE function -- Weird results [Re: JNK]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Your screen output is overwriting.

Add
 Code:
$Rc=SetOption('WrapAtEOL', 'On')
to your script and try again.

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

Top
#201128 - 2010-12-11 12:18 AM Re: READVALUE function -- Weird results [Re: Glenn Barnas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
the value is reversed... think that is what he tries to say.
_________________________
!

download KiXnet

Top
#201129 - 2010-12-11 01:23 PM Re: READVALUE function -- Weird results [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
nope. His data is writing over and over on the same line. That's why its correct in the file but not the screen. The file can represent a long line, either by scrolling or forcibly wrapping the text (depending on the editor used) while the screen does not scroll sideways. When kix runs out of room on a line, it does not wrap to the next line but to the beginning of the current line.

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

Top
#201130 - 2010-12-11 02:09 PM Re: READVALUE function -- Weird results [Re: Glenn Barnas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh...
and I just thought he didn't post the whole thing \:\)

think you right on that.
_________________________
!

download KiXnet

Top
#201182 - 2010-12-16 05:52 PM Re: READVALUE function -- Weird results [Re: Lonkero]
JNK Offline
Fresh Scripter

Registered: 2006-04-11
Posts: 33
Loc: USA
Sorry for the late reply. I have been out of commission for a couple of days.

Yes, the line was wrapping onto of itself in the command window and adding the $Rc=SetOption('WrapAtEOL', 'On') corrected the issue. I knew it would be something silly -- and now that I see the answer, I am ashamed (but not afraid) to admit I missed it.

Thank you to all of the smart people on this board for pointing me in the right direction.

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 (Allen) and 781 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.055 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