#70444 - 2002-10-01 05:30 AM
KixDB - possible?
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
I made a baseline db-connector for pure text but it has some adjustments to be made in the syntax for real usage... anyway, as a testbench or something, it could work.
code:
;need to have utleast 1 filehandle free on open and close ;var namespace $_DB_ may not be used elsewhere in the script ;NO ERROR-CHECKS YET!
function DB($handle, $action, $arg1,optional $arg2) dim $,$temp,$nul select case $action="new" $=execute("global $$_DB_$handle[0]") $arg1=join($arg1,chr(13)) $=execute("$$_DB_$handle[0]=$arg1") case $action="open" $=execute("global $$_DB_$handle[0]") $=10 while open($,$arg1) and $ $=$-1 loop $temp=readline($) $nul=execute("$$_DB_$handle[0]=$temp") $temp=readline($) while not @error $nul=execute("redim preserve $$_DB_$handle[ubound($$_DB_$handle)+1]") $nul=execute("$$_DB_$handle[ubound($$_DB_$handle)]=$temp") $temp=readline($) loop $nul=close($) case $action="close" if exist($arg1) del $arg1 endif $=10 while open($,$arg1,5) and $ $=$-1 loop $nul=execute("for $$temp=0 to ubound($$_DB_$handle) $$nul=writeline($$,$$_DB_$handle[$$temp]) next") $nul=close($) $=execute("redim $$_DB_$handle") case $action="add" $arg1=join($arg1,chr(13)) $nul=execute("redim preserve $$_DB_$handle[ubound($$_DB_$handle)+1]") $nul=execute("$$_DB_$handle[ubound($$_DB_$handle)]=$arg1") case $action="del" $arg1=join($arg1,chr(13)) $nul=execute("for $$temp=0 to ubound($$_DB_$handle) if $$_DB_$handle[$$temp]=$arg1 $$_DB_$handle[$$temp]=$$_DB_$handle[ubound($$_DB_$handle)] $$temp=ubound($$_DB_$handle) redim preserve $$_DB_$handle[ubound($$_DB_$handle)-1] endif next") case $action="mod" $arg1=join($arg1,chr(13)) $nul=execute("for $$temp=0 to ubound($$_DB_$handle) if $$_DB_$handle[$$temp]=$arg1 $$_DB_$handle[$$temp]=$arg2 $$temp=ubound($$_DB_$handle) endif next") endselect endfunction
_________________________
!download KiXnet
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|