Heya Ian
I did put together a test harness, but of course now I can't get the issue to replicate there
I'm still experiencing the freeze-up as described in my main project -- so, it's got to be some odd interaction somewhere else... I'll tell you when I find it.
The code for the test harness is below and I've attached a lookup table file (put in same directory as executable).
sync on
sync rate 0
rem start 3d
make object sphere 1,1
gosub debugSetup
gosub optionSetup
optionLoad()
intervalLookupTime = 2000
nextLookupTime = timer() + intervalLookupTime
lookupText$ = ""
rndText$ = ""
flagQuit = 0
keydown = 0
repeat
text 0,0, "Lookup Test Harness"
text 0,15, "Lookups are being done at a rate of " + str$(int(intervalLookupTime/1000.0)) + " lookups/second"
text 0,30, "Press Up Arrow to increase lookup rate and Down Arrow to decrease lookup rate"
text 0,45, "Press q to quit"
text 0,60, "Press any other key to concat to the current lookup text and do an immediate lookup"
text 0,75, "(the faster you type, the faster the lookups will be)"
text 0,90, "Lookup Text: " + lookupText$
if timer() > nextLookupTime
nextLookupTime = timer() + intervalLookupTime
if lookupText$ <> ""
retval$ = optionGetTag("language", lookupText$)
else
rem do a random lookup
rndText$ = ""
for i = 1 to 6
rndText$ = rndText$ + chr$(rnd(25)+65)
next
retval$ = optionGetTag("language", rndText$)
endif
endif
if scancode() <> 0 and keydown = 0
keydown = 1 : found = 0
if upkey() then inc intervalLookupTime, 100 : found = 1
if downkey() then dec intervalLookupTime, 100 : found = 1
if keystate(16) = 1 then flagQuit=1 : found = 1
if found = 0
lookupText$ = lookupText$ + ENTRY$()
clear entry buffer
retval$ = optionGetTag("language", rndText$)
endif
endif
if scancode() = 0
keydown = 0
endif
sync
until (flagQuit = 1)
debugShutdown()
end
optionSetup:
rem base must be built manually
#constant OPTION_TABLES 1
make lookup OPTION_TABLES
set lookup OPTION_TABLES, "tables", str$(OPTION_TABLES)
#constant OPTION_UNDEF "***UNDEFINED***"
#constant OPTION_PATH ""
rem copied over from system module to
rem create test harness
#constant SYSTEM_FILE_TABLE 1
#constant SYSTEM_FILE_OPTION 2
global systemNextFreeLookup as integer
return
debugSetup:
rem copied here for test harness
OPEN LOG "lookup_test.log", 1
SET LOG TAG 0, "[SYSTEM] INFO ", ""
SET LOG TAG 1, "[SYSTEM] WARN ", ""
SET LOG TAG 2, "[SYSTEM] ERROR ", ""
#constant DEBUGINFO 0
#constant DEBUGWARN 1
#constant DEBUGERROR 2
debugWrite(DEBUGINFO,"---- SYSTEM STARTUP ---")
return
function debugShutdown()
rem copied here for test harness
CLOSE LOG
endfunction
function debugWrite(level as integer, msg$ as string)
rem copied here for test harness
tstamp$ = systemGetRealDateTime("/"," ",":")
WRITELN LOG level, "%s :: %s" , tstamp$, msg$
endfunction
function systemFreeLookup()
rem copied here for test harness
repeat
inc systemNextFreeLookup
until lookup exist(systemNextFreeLookup) = 0
endfunction systemNextFreeLookup
function systemGetRealDateTime(dsep$,dtsep$,tsep$)
rem copied here for test harness
date$ = get date$()
time$ = get time$()
month$ = left$(date$,2)
day$ = mid$(date$,4) + mid$(date$,5)
year$ = "20" + right$(date$,2)
date$ = year$+dsep$+month$+dsep$+day$
hour$ = left$(time$,2)
minutes$ = mid$(time$,4) + mid$(time$,5)
seconds$ = right$(time$,2)
time$ = hour$+tsep$+minutes$+tsep$+seconds$
datetime$=date$+dtsep$+time$
endfunction datetime$
function optionGetTag(tableName$, key$)
local retval$ as string
retval$ = OPTION_UNDEF
rem first find the tableID
if search lookup (OPTION_TABLES, tableName$) = 1
if lookup is valid(OPTION_TABLES)
tableid = intval(lookup current value$(OPTION_TABLES))
first lookup OPTION_TABLES
rem now find the key/value pair in the right table
if search lookup(tableid, key$) = 1
if lookup is valid(tableid)
retval$ = lookup current value$(tableid)
else
debugWrite(DEBUGWARN,"optionGetTag lookup invalid for table: " + str$(tableid))
endif
else
debugWrite(DEBUGWARN,"optionGetTag lookup not found for table: " + str$(tableid) + " and key: " + key$)
first lookup tableid
endif
else
debugWrite(DEBUGWARN,"optionGetTag table lookup invalid for table: " + tablename$)
endif
else
debugWrite(DEBUGWARN,"optionGetTag table lookup not found for table: " + tablename$)
endif
endfunction retval$
function optionUpdateTag(tableName$, key$, value$)
local tableid as integer
rem first find the tableID
if search lookup (OPTION_TABLES, tableName$) = 1
if lookup is valid(OPTION_TABLES)
tableid = intval(LOOKUP CURRENT VALUE$(OPTION_TABLES))
endif
else
tableID = systemFreeLookup()
make lookup tableID
set lookup OPTION_TABLES, tableName$, str$(tableID)
debugWrite(DEBUGINFO,"optionUpdateTag created table " + str$(tableID) + ". " + tableName$)
endif
rem now set the key/value pair in the table
set lookup tableid, key$, value$
debugWrite(DEBUGINFO,"optionUpdateTag created key " + key$ + " in table " + str$(tableID) + ". " + tableName$)
endfunction
function optionLoad()
filename$ = OPTION_PATH + "tables.ini"
if file exist(filename$)
open to read SYSTEM_FILE_TABLE, filename$
while not file end(SYSTEM_FILE_TABLE)
read string SYSTEM_FILE_TABLE, table$
filename$ = OPTION_PATH + table$ + ".ini"
if file exist(filename$)
open to read SYSTEM_FILE_OPTION, filename$
while not file end(SYSTEM_FILE_OPTION)
read string SYSTEM_FILE_OPTION, dat$
split string dat$,"="
optionUpdateTag(table$, get split word$(1), get split word$(2))
endwhile
close file SYSTEM_FILE_OPTION
endif
endwhile
close file SYSTEM_FILE_TABLE
endif
endfunction
function optionSave()
local myTable as integer
myTable = 1
while lookup exist(OPTION_TABLES)
FIRST LOOKUP OPTION_TABLES
while lookup is valid(OPTION_TABLES)
filename$ = OPTION_PATH + LOOKUP CURRENT KEY$(OPTION_TABLES) + ".ini"
myTable = intval(LOOKUP CURRENT VALUE$(OPTION_TABLES))
while lookup exist(myTable)
if file exist(filename$)
delete file filename$
endif
open to write SYSTEM_FILE_OPTION, filename$
FIRST LOOKUP myTable
while lookup is valid(myTable)
dat$ = LOOKUP CURRENT KEY$(myTable) + "=" + LOOKUP CURRENT VALUE$(myTable)
write string SYSTEM_FILE_OPTION, dat$
next lookup myTable
endwhile
close file SYSTEM_FILE_OPTION
endwhile
next lookup OPTION_TABLES
endwhile
endwhile
endfunction