Page 1 of 1 1
Topic Options
#71869 - 2002-11-28 05:00 AM enumvalue() not returning all values.
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
ok, has anyone had any problem with enumvalue() not returning all of the values that are located in a key?

using 4.12...I am stll doing some testing, and will post as I find out more.

[ 28. November 2002, 05:00: Message edited by: Bryce ]

Top
#71870 - 2002-11-28 05:03 AM Re: enumvalue() not returning all values.
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
What key?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#71871 - 2002-11-28 05:07 AM Re: enumvalue() not returning all values.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
dude your avatar is awesome...
scared the heck out of me! [Eek!]
_________________________
!

download KiXnet

Top
#71872 - 2002-11-28 05:39 AM Re: enumvalue() not returning all values.
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
a key made by the user in the hkcu\software.... part of the registry.

I don't know if it is a problem with enumvalue(), or just a bug in my code that i am not finding [Smile]

but, some testing that I did is displaying all of the entries in a key. I then compared the list made by my script output to the registry, I found a few entries that enumvalue did not return.

But after running the same script a few times in a row, it displayed all of the entries...

I could post my code..... it is only 10k [Smile] and only a small chunk of a much larger script 140k.

Top
#71873 - 2002-11-28 05:57 AM Re: enumvalue() not returning all values.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so do that [Wink]

as MCA has been silently lately, we haven't seen any long scripts in 4 months [Frown]
_________________________
!

download KiXnet

Top
#71874 - 2002-11-28 06:13 AM Re: enumvalue() not returning all values.
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
ooook!

a brief explanation, i am putting entries into the registry and they will only be kept there for the length of the $purgetime.

What I have been seeing is.... say i run the script against data that has been in place for a number of hours since I last ran this test script, it looks like enumval is not returning all of the entries. But, run the script 3 or 4 times in a row and it will eventually purge all of the old entries.

all of this action is taking place in the BUILDPD function.

code:
break on

;? serialtime("23:59")
;exit(0)
$database = "HKEY_CURRENT_USER\Software\OPDB"


buildpd

exit(0)

Function CheckOPDBEngine
dim $pilotQue, $i, $temp

$pilotQue = getdb($database,"status","onlinepilots")

while not @error
$temp = enumval($database + "\onlinepilots\inuse",$i)
$i = $i + 1

loop


endfunction


function BUILDPD
dim $pilots, $totalpilots, $groupsize,$i, $temp, $ts, $datedif, $timedif, $purgetime, $pilot,
$totalcount

$pilots = getonlinepilots

if not @error
$totalpilots = ubound($pilots)

for $i = 0 to $totalpilots
$temp = split($pilots[$i],",")
putdb($database,"OnlinePilots",$temp[2],@date+","+@time)
next
else
exit(@error)
endif
if not getdb($database,"settings","Purgetime")
$purgetime = "01:00:00"
putdb($database,"settings","Purgetime",$purgetime)
else
$purgetime = getdb($database,"settings","Purgetime")
endif

$i = 0
$Pilot = enumvalue($database + "\Onlinepilots",$i)
while not @error
? $i " " $pilot
$ts = split(getdb($database,"onlinepilots",$Pilot),",")
if ubound($ts) = 1
$dateDif = serialdate(@date) - serialdate($ts[0])
select
case $datedif = 1
$timedif = (val(serialtime("23:59:59")) - val(serialtime($ts[1]))) + val(serialtime("00:10:00"))
case $datedif > 1
$ = delvalue($database + "\onlinePilots",$pilot)
case 1
$timedif = (val(serialtime(@time)) - val(serialtime($ts[1])))
endselect

;? $ts[1] " " $timedif " " serialtime($purgetime) " " $pilot
if val($timedif) > val(serialtime($purgetime))
$ = delvalue($database + "\onlinePilots",$pilot)
else
$totalcount = $totalcount+1
endif
endif
$i = $i + 1
$Pilot = enumvalue($database + "\Onlinepilots",$i)
loop
putdb($database,"status","OnlinePilots",$totalcount)
$ = deltree($database + "\onlinepilots\inuse")
endfunction

function PutDB($database,$section,$key,$data)
dim $nul
$nul = writevalue($database + "\" + $section,$key,$data,"REG_SZ")
exit(@error)
endfunction

function GetDB($database,$section,$key)
$getdb = readvalue($database + "\" + $section,$key)
exit(@error)
endfunction



function GetonlinePilots()
dim $doc, $data, $octs, $sols, $quan, $count, $array, $delim, $pilot
$delim = ","

if not $josshdownload
$josshdownload = createobject("microsoft.xmlhttp")
if @Error <> 0
exit(@error)
endif
endif

$Josshdownload.open("GET", "http://www.jossh.com/jgeng/PilotViewer?list=onlinepilotsonly", not 1)
$josshdownload.send

while $josshdownload.readystate <> 4
;busyflash_event()
;$nul = execute($gui.DoEvents(1))
sleep(0.0625)
loop

if $josshdownload.responsetext

$data = $josshDownload.responsetext
$data = split($data,'VALIGN=')
if ubound($data) = 0
exit(1)
endif
$data = split($data[3],"<TD BGCOLOR=")

$sols = split($data[1],"<BR>")
$octs = split($data[2],"<BR>")
$quan = split($data[3],"<BR>")

$sols[0] = substr($sols[0],instr($sols[0],"<IMG"))
redim preserve $sols[ubound($sols)-1]

for $count = 0 to ubound($sols)
$pilot = $sols[$count]
$sols[$count] = "S" + $delim
if instr($pilot, "Honor Guard")
$sols[$count] = $sols[$count] + "hg" + $delim
else
$sols[$count] = $sols[$count] + "civ" + $delim
endif
$pilot = split($pilot,">")
$pilot = substr($pilot[ubound($pilot)-1],1,len($pilot[ubound($pilot)-1])-3)
$sols[$count] = $sols[$count] + $pilot
next

$octs[0] = substr($octs[0],instr($octs[0],"<IMG"))
redim preserve $octs[ubound($octs)-1]

for $count = 0 to ubound($octs)
$pilot = $octs[$count]
$octs[$count] = "O" + $delim
if instr($pilot, "Honor Guard")
$octs[$count] = $octs[$count] + "hg" + $delim
else
$octs[$count] = $octs[$count] + "civ" + $delim
endif
$pilot = split($pilot,">")
$pilot = substr($pilot[ubound($pilot)-1],1,len($pilot[ubound($pilot)-1])-3)
$octs[$count] = $octs[$count] + $pilot
next

$quan[0] = substr($quan[0],instr($quan[0],"<IMG"))
redim preserve $quan[ubound($quan)-2]

for $count = 0 to ubound($quan)
$pilot = $quan[$count]
$quan[$count] = "Q" + $delim
if instr($pilot, "Honor Guard")
$quan[$count] = $quan[$count] + "hg" + $delim
else
$quan[$count] = $quan[$count] + "civ" + $delim
endif
$pilot = split($pilot,">")
$pilot = substr($pilot[ubound($pilot)-1],1,len($pilot[ubound($pilot)-1])-3)
$quan[$count] = $quan[$count] + $pilot
next

dim $array[ubound($sols) + ubound($Octs) + ubound($quan)+2]


$count = 0
for each $pilot in $sols
$array[$count] = $pilot
$count = $count+1
next

for each $pilot in $octs
$array[$count] = $pilot
$count = $count+1
next

for each $pilot in $quan
$array[$count] = $pilot
$count = $count+1
next


$getonlinepilots = $array
else
exit(1)
endif

$josshdownload.abort

endfunction

function SerialTime($TorS)
; Syntax: SerialTime(Time | Serial)
; Where Time is a time string in HH:MM[:SS] format or
; Serial is a time serial number (seconds since midnight) 1 - 86399
; If Time is supplied, SerialTime will return the seconds since midnight.
; If seconds since midnight is supplied, SerialTime will return a time.
; DEPENDENCIES: word(), abs(), mod()
dim $Hours, $Minutes, $Seconds, $Serial, $Error
$Error = 0
if instr($TorS,":") ; Time supplied
$TorS = "" + $TorS ; Cast to string
if len($TorS) > 4 and len($TorS) < 9
$Hours = 0 + word($TorS,1,":") ; Hours as integer for calculation
if $Hours > 23 $Error = 1 endif
$Minutes = 0 + word($TorS,2,":") ; Minutes as integer for calculation
if $Minutes > 59 $Error = 1 endif
$Seconds = 0 + word($TorS,3,":") ; Seconds as integer for calculation
if $Seconds > 59 $Error = 1 endif
$Serial = ($Hours * 3600) + ($Minutes * 60) + $Seconds
if $SerialTime > 86399 $Error = 1 endif
if $Error
$SerialTime = "-1" ; Error
else
$SerialTime = "" + $Serial ; Return as string
endif
else
$SerialTime = "-1" ; Error
endif
else ; Seconds supplied
$TorS = 0 + $TorS ; Cast to integer for calculation
if $TorS <= 86399 and $TorS >= 0
$Hours = $TorS / 3600
$TorS = $TorS - ($Hours * 3600)
$Hours = "" + $Hours
$Hours = substr("00",1,2 - len($Hours)) + $Hours
$Minutes = $TorS / 60
$TorS = $TorS - ($Minutes * 60)
$Minutes = "" + $Minutes
$Minutes = substr("00",1,2 - len($Minutes)) + $Minutes
$Seconds = "" + $TorS
$Seconds = substr("00",1,2 - len($Seconds)) + $Seconds
$SerialTime = $Hours + ":" + $Minutes + ":" + $Seconds ; Return as string
else
$SerialTime = "-1" ; Error
endif
endif
endfunction

function abs($Expr)
;returns the absolute value of a number
$Expr=0+$Expr
if $Expr<0
$Expr=-1*$Expr
endif
$abs=$Expr
endfunction

FUNCTION Word($sStr, $iWrdNum, optional $strWS)
; Syntax: Word("string",number, ["white space characters"])
; Word number may be negative, in which case, words will be counted
; from the right of the string. I.e. -1 will return the last word in the string.
DIM $iWrdCtr, $iLen, $iStart, $iFinish, $iStep, $i
$Word='' $sStr=''+$sStr $strWS=''+$strWS
$iWrdNum=0+$iWrdNum $iLen=Len($sStr) $iWrdCtr=0
IF $strWS = '' $strWS = Chr(9) + Chr(32) + ',' ENDIF
IF $iWrdNum >= 0 ; Parse string forward
$iStart=1 $iFinish=$iLen $iStep=1
ELSE ; Parse string backward
$iStart=$iLen $iFinish=1 $iStep=-1
$iWrdNum=-1*$iWrdNum
ENDIF
IF $sStr <> '' AND $iWrdNum > 0
FOR $i = $iStart TO $iFinish STEP $iStep
IF InStr($strWS,SubStr($sStr,$i,1)) ; If whitespace
WHILE InStr($strWS,SubStr($sStr,$i,1)) AND ($i <= $iLen) ; skip it
$i=$i+$iStep
LOOP
ELSE ; If non-whitespace
$iWrdCtr = $iWrdCtr + 1 ; increment word counter
; If this is the correct word number, extract it
IF $iWrdCtr = $iWrdNum
WHILE NOT InStr($strWS,SubStr($sStr,$i,1)) AND ($i <= $iLen)
; Extract it in the right order!
IF $iStep = 1
$Word = $Word + SubStr($sStr,$i,1)
ELSE
$Word = SubStr($sStr,$i,1) + $Word
ENDIF
$i=$i+$iStep
LOOP
ELSE ;otherwise, skip the word
WHILE NOT InStr($strWS,SubStr($sStr,$i,1)) AND ($i <= $iLen)
$i=$i+$iStep
LOOP
ENDIF
ENDIF
$i=$i-$iStep
NEXT
ENDIF
ENDFUNCTION

function SerialDate($ExpD)
; Author: ScriptLogic Corporation
; parameter ($ExpD) must be a date (in the form of yyyy/mm/dd)
; or an integer previously derived by this function.
; if passed a date, it returns an integer.
; If passed an integer, it returns the date.
; Integers can be used for general-purpose math computations on dates
; and then converted back to dates by calling this function again.
; Algorithms were obtained from: http://www.capecod.net/~pbaum/date/date0.htm
dim $z,$h,$a,$b,$c,$y,$m,$d
if instr($ExpD,'/') ; date passed
$y=val(substr($ExpD,1,4))
$m=val(substr($ExpD,6,2))
$d=val(substr($ExpD,9,2))
if $m<3
$m=$m+12
$y=$y-1
endif
; return an integer
$SerialDate=$d+(153*$m-457)/5+365*$y+$y/4-$y/100+$y/400-306
else ; integer passed
$z=0+$ExpD+306 ; cast numeric
$h=100*$z-25
$a=$h/3652425
$b=$a-$a/4
$y=(100*$b+$h)/36525
$c=$b+$z-365*$y-$y/4
$m=(5*$c+456)/153
$d=$c-(153*$m-457)/5
if $m>12
$y=$y+1
$m=$m-12
endif
$m=right('0'+$m,2)
$d=right('0'+$d,2)
; return a string date
$SerialDate=''+$y+'/'+$m+'/'+$d
endif
endfunction



[ 28. November 2002, 07:05: Message edited by: Bryce ]

Top
#71875 - 2002-11-28 06:35 AM Re: enumvalue() not returning all values.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
quickies...
what error you are trying to catch in:
code:
while not @error
$Pilot = enumvalue($database + "\Onlinepilots",$i)

mmm... that is sure that it's not for enumval...
_________________________
!

download KiXnet

Top
#71876 - 2002-11-28 06:54 AM Re: enumvalue() not returning all values.
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
hmmm good point there....
Top
#71877 - 2002-11-28 06:58 AM Re: enumvalue() not returning all values.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
just checked th sreg()...
I'm not sure does the enumval set the error properly at all.
it migh just be that only way to check if avail is length, not sure though...

that was problem in some build a long time ago, not sure if anymore.
_________________________
!

download KiXnet

Top
#71878 - 2002-11-28 07:04 AM Re: enumvalue() not returning all values.
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
ok i moved things around enumvalue() is the last command in the loop now... and still i had an entry that was not returned, does not show up at all from the line

code:
? $i "	" $pilot

when i ran the code a 2nd time one of the entries that it missed showed up as entry 106 of 158.

(i edited the above post with the changed code.)

Top
#71879 - 2002-11-28 07:18 AM Re: enumvalue() not returning all values.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so...
what is total count and does it show normally approx same amount or does not vary?
_________________________
!

download KiXnet

Top
#71880 - 2002-11-28 07:27 AM Re: enumvalue() not returning all values.
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
The total count is always changing. I tried to recreate this error in a controled enviroment with out success.... [Frown]
Top
#71881 - 2002-11-28 07:36 AM Re: enumvalue() not returning all values.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I think I got it.
not sure, but think about it.

you query on the stack and on every query, if right condition remove a bit of the stack...
the stack numbers change so you would need to start from scratch to get the correct ones...

get it?
like, removing a line from excel sheet and then continuing to count... there will be one hopped over. and what more you remove, that more you have failures???

any sence?

[ 28. November 2002, 07:37: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#71882 - 2002-11-28 07:39 AM Re: enumvalue() not returning all values.
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
AAHHH!!! that makes sense!!

let me move things around a bit...

Top
#71883 - 2002-11-28 07:56 AM Re: enumvalue() not returning all values.
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
ok that seems to be the cause of the missing entries from enumvalue()

Thanks!!!!

I am going to have to file this little bit of information away in the back of my head for future reference!

Top
#71884 - 2002-11-28 10:14 PM Re: enumvalue() not returning all values.
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You might also want to use the ArrayEnumValue() UDF.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 837 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.065 seconds in which 0.023 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