User friendly database manager
Jan 10, 2009 14:50:30 GMT -5
Post by marcioc on Jan 10, 2009 14:50:30 GMT -5
I would like to share with you a very user friendly database manager, which can delete or create columns in anywhere in the table without losing any information. In addition it can handle very well the primary key column without messing up the table indexes.
Finally, you can edit your table information directly in the browse on the screen.
Comments are very welcome. Marcio Cracel.
Finally, you can edit your table information directly in the browse on the screen.
Comments are very welcome. Marcio Cracel.
'*************** Manage tables in any SQLITE Database V1.0******************
'***************Marcio Cracel Potomac MD 12/18/2008 *********
global #sql
global browsepg,lenpg,sele,order,ドルrec,lfield,ドルduplicate,ドルapp,filtra,ドルrows,andor,ドルdontclose
filtra$=""
browsepg=1
dontclose=0
andor$="and"
lenpg=8
sele=3
order$=""
on error goto [erro]
cssclass "table", "{ width: 750px; border: 6px ridge #CCF ; border-spacing: 2px }"
cssclass "tr", "{ background: #CCF }"
[start]
cls
browsepg=1
html "<table border='2' align='center'><th> DataBase Manager </th></table>"
html "<table border='2' align='center'><th>":print "Inform Database name";
html "<input type='file' id='file' name ='file' value='c:\rbp101b3\public\SQLite.db' />"
button #a,"Confirm",[dbase]: html "</th><th>"
button #b,"Exit",[end]:html "</th></table>"
x$=setfocus$("file")
wait
[dbase]
dbase$ = #request get$("file")
'*** Force an error if file is a database *********
sqliteconnect #sql,dbase$
#sql execute("SELECT * FROM sqlite_master")
#sql disconnect()
'dbase$="c:\rbp101b3\public\SQLite.db"
if len(dbase$)=0 then goto [start]
[loop]
cls
order$=""
filtra$=""
a=showtables(dbase$)
browsepg=1
wait
[menu1]
'************* Show Tables available **********************
tabla$=EventKey$
if tabla$="#newtable" then goto [create]
[menu2]
sele =3
cls
a$=use$(dbase,ドルtabla,ドルorder,ドル"")
lfield$= trim$(#sql COLUMNNAMES$())
#sql disconnect()
a$=use$(dbase,ドルtabla,ドルorder,ドルfiltra$)
a$=browsex$(dbase,ドルtabla$)
name$="name"+"/"+str$(rec)+"/1"
a$=setfocus$(name$)
wait
'********** Update # Rows on Screen ******
[lenpg]
lenpg = val(#request get$("lenpg"))
andor$ = #request get$("group1")
goto [menu2]
'**********Filter *****************
[filter]
'cls
app=1
andor$= #request get$("group1")
mes$="Click on the column to filter the table"
goto [comm]
'********** Order By **********************
[order]
'cls
andor$ = #request get$("group1")
mes$="Click on the column to order the table"
app=0
[comm]
'************** Display Table Columns *****************
html "<table border='2' align='center'><th>"+mes$+"</th></table>"
i=1
j=1
html "<table border='2' align='center'>"
while len(word$(lfield,ドルi,",")) > 0
camp$=word$(lfield,ドルi,",")
html "<th>":button #camp,ドルcamp,ドル[order2]:html "</th>"
i=i+1
j=j+1
if j=6 then
html "<tr> </tr>"
j=1
end if
wend
if app=0 then
html "<th>":button #clear,"Clear order",[order2]:html "</th>":j=j+1
else
html "<th>":button #clear,"Clear Filter",[filter3]:html "</th>":j=j+1
end if
'**** Complete remaining cells with ... ****************
while j > 1 and j <5
html "<th>":print "...";:html "</th>"
j=j+1
wend
html "<th>":button #c,"Cancel",[menu2]:html "</th></table>"
'a$=use$(dbase,ドルtabla,ドルorder,ドルfiltra$)
'a$=browsex$(dbase,ドルtabla$)
wait
[order2]
'***** filter ********
if app=1 then
filt$=EventKey$
html "<table border='2' align='center' ><th>":print "Inform "+filt$+" Value ";
html "</th><th><input type='text' name='filter' id='filter' /></th><th>"
button #a,"Confirm",[filter2]:print " ";:html "</th><th>":
button #c,"Cancel",[menu2]:html "</th></table>"
a$=setfocus$("filter")
wait
end if
order$=EventKey$
'***** Clear Order By *********
if order$ = "#clear" then order$=""
goto [menu2]
'********* Filter part 2 *************
[filter2]
if len(filtra$)>0 then filtra$=filtra$+" "+andor$+" "
filtra$= filtra$+" "+filt$+" like '%"+#request get$("filter")+"%'"
goto [menu2]
'******* Clear Filter *********
[filter3]
filtra$=""
andor$="and"
goto [menu2]
'********Export Data ***********************
[exportd]
html "<table border='2' align='center' ><th> Inform file name "
html "<input type='text' name='export' id='export' /></th><th> Inform Separator </th><th>"
html "<input type='text' name='deli' size='1' /></th><th>"
button #a,"Confirm",[exp2]:print " ";:button #c,"Cancel",[menu2]
html "</th></table>"
x$=setfocus$("export")
wait
[exp2]
fname$= #request get$("export")
deli$= #request get$("deli")
if len(fname$)=0 then goto [menu2]
open fname$ for output as #f
a$=use$(dbase,ドルtabla,ドルorder,ドルfilter$)
rows = #sql ROWCOUNT()
for j=1 to rows
resulta$ = #sql nextrow$(deli$)
print #f,resulta$
next j
close #f
html "<table order='2' align='center'><th>": print j;" ";"Rows copied";
html "</th><th>":button #a,"Continue..",[menu2]:html "</th></table>"
wait
goto [menu2]
'*********Import data ***********************
[importd]
html "<table border='2' align='center' ><th> Inform file name "
html "<input type='text' name='import' id='import' /></th><th> Inform Separator </th><th>"
html "<input type='text' name='deli' size='1' /></th><th>"
button #a,"Confirm",[imp2]:print " ";:button #c,"Cancel",[menu2]
html "</th></table>"
x$=setfocus$("import")
wait
[imp2]
tablaux$="xyz"
fname$= #request get$("import")
deli$= #request get$("deli")
if len(fname$)=0 then goto [menu2]
'****** Check if file exist ******
files #f,fname$
open fname$ for input as #f
cont=0
sqliteconnect #sql,dbase$
sql$="create temporary table xyz ("+lfield$+")"
#sql execute(sql$)
reca=0
while not(eof(#f))
line input #f,resulta$
result$=""
r=1
while len(word$(lfield,ドルr," "))<>0
name$=word$(lfield,ドルr,",")
if r>1 then result$=result$+","
result$= result$+""""+word$(resulta,ドルr,deli$)+""""
r=r+1
wend
'x$=append$(dbase,ドルtabla,ドルlfield,ドルresult$)
'sql$="insert into "+tabla$+" ("+lfield$+") values ("+result$+")"
sql$="insert into "+tablaux$+" ("+lfield$+") values ("+result$+")"
reca=reca+1
#sql execute(sql$)
wend
sql$="insert into "+tabla$+" select "+lfield$+" from "+tablaux$
#sql execute(sql$)
#sql disconnect()
html "<table order='2' align='center'><th>": print reca;" ";"Rows included";
html "</th><th>":button #a,"Continue..",[menu2]:html "</th></table>"
wait
goto [menu2]
'********** Modify in browse ****************
[browse2]
andor$ = #request get$("group1")
updatex=0
dim replaz$(lenpg)
until=rec+lenpg-1
if until > rows then until=rows
j=1
'****** Look for colums modified ***********
for x= rec to until
replaz$(j)=""
x$=seek$(dbase,ドルtabla,ドルx)
resulta$ = #sql nextrow$("|")
#sql disconnect()
filter$=filt$(lfield,ドルresulta$) 'build filter
n$="name/"+str$(x)+"/"
result$=repla$(lfield,ドルn$)
if duplicate$ <>resulta$ then
'a$=replace$(dbase,ドルtabla,ドルfilter,ドルresult$)
replaz$(j)=filter$+"<>"+result$
updatex=updatex+1
end if
j=j+1
next x
'**** update modified columns ******
for j=1 to lenpg
if len(replaz$(j))>0 then
filter$=word$(replaz$(j),1,"<>")
result$=word$(replaz$(j),2,"<>")
a$=replace$(dbase,ドルtabla,ドルfilter,ドルresult$)
end if
next j
goto [menu2]
'******* Delete in a browse *******************
[browdel]
a$= EventKey$
html "<table border='2' align='center' > <th> "
button #c,"Confirm Deletion",[confdel]: html "</th><th>"
button #a,"Cancel",[menu2]: html "</th></table>"
wait
[confdel]
'******** Delete all /specific row ****************
if a$="#vacuum" then
x$=droptable$(dbase,ドルtabla$)
x$=create$(dbase,ドルtabla,ドルlfield$)
else
'**** Delete a specific row ************
rec=val(a$)
if rec=0 then goto [menu2]
a$=use$(dbase,ドルtabla,ドルorder,ドル"")
rows= #sql rowcount()
if rec > rows then goto [menu2]
for x=1 to rows
result$ = #sql nextrow$("|")
if x=rec then exit for
next x
#sql disconnect()
filter$=filt$(lfield,ドルresult$)
a$=delete$(dbase,ドルtabla,ドルfilter$)
end if
goto [menu2]
'********* Insert new record in Browse **************
[brownew]
result$=""
r=1
while len(word$(lfield,ドルr," "))<>0
name$=wordx$(lfield,ドルr,",")
if r>1 then
result$=result$+","+"'"+"'"
else
result$=resul$+"' new-"+str$(rows+1)+"'"
end if
r=r+1
wend
a$=append$(dbase,ドルtabla,ドルlfield,ドルresult$)
rows= #sql rowcount()
if len(order$)=0 then
browsepg=int((rows-1)/lenpg+1)
rec=rows
else
browsepg=1
rec=1
end if
goto [menu2]
'********* Browse go top *******************
[browtop]
browsepg=1
rec=1
goto [menu2]
'******** Browse go bottom ****************
[browbot]
rec=rows
browsepg=int((rows-1)/lenpg+1)
goto [menu2]
'*********** Delete a table ****************************
[delete]
html "<table border='2' align='center'><th>":button #c,"confirm table deletion",[conf]:print " ";
button #d,"Cancel",[menu2]:html "</th></table>"
wait
[conf]
a$=droptable$(dbase,ドルtabla$)
goto [loop]
'************ Create a table ************************
[create]
html "<table border='2' align='center'><th>":Print "Table name":html "<input type='text' id='table' name='table' /></th>"
html "<th>":print "First Column name":html "<input type='text' name='field' /></th>"
html "<th>":print "First Column Type"
html "<select name='type'>
<option value='Char'>Char</option>
<option value='Integer'>Integer</option>
<option value='Varchar'>Varchar</option>
<option value='Numeric'>Numeric</option>
<option value='Text'>Text</option>
</select>"
html "</th><th>":print "Primary key": html "<input type='checkbox' name='prima' /></th>"
html "<th>":button #c,"confirm",[confa]: print " ":button #d,"Cancel",[loop]:html "</th> </table>"
x$=setfocus$("table")
wait
[confa]
ntable$= #request get$("table")
campos$= #request get$("field")
type$= #request get$("type")
prima$= #request get$("prima")
if len(ntable$)=0 or len(campos$)=0 then
html "<table border='2' align='center'><th>Error : Empty field ":button #f,"Continue",[loop]:html "</th></table>"
wait
end if
ext$=campos$+" "+type$
if prima$="on" then ext$=ext$+" primary key "
a$=create$(dbase,ドルntable,ドルext$)
tabla$=ntable$
goto [menu2]
'*********** Modify a table *******************
[mfield]
app=0
'cls
oper$=mid$(EventKey,2,200ドル)
if oper$="add" then
mes$="Click on the column where the new column will be inserted"
else
mes$="Click on the column to be dropped"
end if
html "<table border='2' align='center'><th>"+mes$+"</th></table>"
i=1
j=1
'********* Display Columns ***********************
html "<table border='2' align='center'>"
while len(word$(lfield,ドルi,",")) > 0
camp$=word$(lfield,ドルi,",")
if oper$="add" then
html "<th>":button #camp,ドルcamp,ドル[add1]:html "</th>"
else
html "<th>":button #camp,ドルcamp,ドル[del2]:html "</th>"
end if
i=i+1
j=j+1
if j=6 then
html "<tr> </tr>"
j=1
end if
wend
'******** Complete the remaining cells with ...************
while j > 1 and j <5
html "<th>":print "...";:html "</th>"
j=j+1
wend
if oper$="add" then html "<th>":button #attheend,"At_the_end",[add1]:html "</th>"
html "<th>":button #c,"Cancel",[menu2]:html "</th></table>"
'a$=use$(dbase,ドルtabla,ドルorder,ドルfiltra$)
'a$=browsex$(dbase,ドルtabla$)
wait
'*********** Add new Column *******************
[add1]
'cls
if EventKey$="#attheend" then
app=1
else
i=instr(lfield,ドルEventKey$)
end if
'******** Display the column types ****************
'a$=showcolumn$(tabla,ドルlfield$)
html "<table border='1' align='center'><th>":print "Column name"
html "<input type='text' name='field' id='add' /></th>"
html "<th>":print "Column Type"
html "<select name='type'>
<option value='Char'>Char</option>
<option value='Integer'>Integer</option>
<option value='Varchar'>Varchar</option>
<option value='Numeric'>Numeric</option>
<option value='Text'>Text</option>
</select>"
html "</th><th>":print "Primary key": html "<input type='checkbox' name='prima' /></th>"
html "</th>"
html "<th>":button #c,"confirm",[add2]: print " "
button #d,"Cancel",[menu2]
html "</th> </table>"
'a$=use$(dbase,ドルtabla,ドルorder,ドルfiltra$)
'a$=browsex$(dbase,ドルtabla$)
a$=setfocus$("add")
wait
'*********** Add Column part2 ********************
[add2]
campos$= #request get$("field")
type$= #request get$("type")
prima$= #request get$("prima")
if prima$="on" then type$=type$+" primary key "
if len(campos$)=0 then
html "<table border='2' align='center'><th>Error : Empty field ":button #f,"Continue",[loop]:html "</th></table>"
wait
end if
'***** Insert new column at the end ************
if app=1 then
a$=altertable$(dbase,ドルtabla,ドルcampos$+" "+type,ドルoper$)
a$=replace$(dbase,ドルtabla,ドル"",campos$+"=''")
goto [menu2]
end if
'*********** Delete Column Part 2 ******************************
[del2]
tablaux$="xyz"
if oper$="add" then
mfield$=lfield$
pfield$=mid$(lfield,1,ドルi-1)+campos$+","+mid$(lfield,ドルi,200)
else
i=instr(lfield,ドルEventKey$)
mfield$=trim$(mid$(lfield,1,ドルi-1)+mid$(lfield,ドルi+len(EventKey$)+1,len(lfield$)))
if mid$(mfield,ドルlen(mfield$),1)="," then mfield$=mid$(mfield,1,ドルlen(mfield$)-1)
end if
'******* Create auxiliary table **********
'In case of crash the file will be saved in xyz table
dontclose=1
sqliteconnect #sql,dbase$
sql$="create temporary table xyz ("+mfield$+")"
#sql execute(sql$)
sql$="insert into "+tablaux$+" select "+mfield$+" from "+tabla$
#sql execute(sql$)
if oper$="add" then
mfield$=pfield$
a$=altertable$(dbase,ドルtablaux,ドルcampos$+" "+type,ドルoper$)
a$=replace$(dbase,ドルtablaux,ドル"",campos$+"=''")
end if
'******* Update current table ***********
a$=droptable$(dbase,ドルtabla$)
a$=create$(dbase,ドルtabla,ドルmfield$)
sql$="insert into "+tabla$+" select "+mfield$+" from "+tablaux$
#sql execute(sql$)
#sql disconnect()
dontclose=0
goto [menu2]
'**********Browse PGUP /PGDN ***********************
[pgdn]
browsepg=browsepg+1
goto [menu2]
[pgup]
browsepg=browsepg-1
goto [menu2]
'**********End the Program *************************
[end]
cls
end
'*********Error treatment ****************
[erro]
a$=alerta$("Error "+Err$)
#sql disconnect()
wait
'*******************Set filter ******************
function filt$(lcamp,ドルstrin$)
filt$=""
r=1
while len(word$(lcamp,ドルr,","))<>0
if r>1 then filt$=filt$+" and "
name$=trim$(word$(lcamp,ドルr,","))
datax$=wordx$(strin,ドルr,"|")
if datax$="|" then datax$=""
filt$=filt$+name$+" like "+"'"+datax$+"'"
r=r+1
'exit while
wend
end function
'***************set the update information ************************
function repla$(lcamp,ドルfcamp$)
repla$=""
duplicate$=""
r=1
while len(word$(lcamp,ドルr," "))<>0
if r > 1 then duplicate$=duplicate$+"|"
name$=word$(lcamp,ドルr,",")
if r>1 then repla$=repla$+","
readx$=fcamp$+str$(r)
datax$= #request get$(readx$)
duplicate$=duplicate$+datax$
name$=trim$(word$(lcamp,ドルr,","))
repla$=repla$+name$+" = '"+datax$+"'"
r=r+1
wend
end function
'******************* Database Functions*************************************************
Function create$(db,ドルtabla,ドルcampo$)
if dontclose=0 then sqliteconnect #sql,db$
tabla$=trim$(tabla$)
sql$="create table "+tabla$+"("+campo$+")"
#sql execute(sql$)
if dontclose=0 then #sql disconnect()
end function
Function append$(db,ドルtabla,ドルcamp,ドルvalue$)
if dontclose=0 then sqliteconnect #sql,db$
sql$="insert into "+tabla$+" ("+camp$+") values ("+value$+")"
#sql execute(sql$)
if dontclose=0 then #sql disconnect()
end function
Function use$(db,ドルtabla,ドルord,ドルfilter$)
sqliteconnect #sql,db$
if len(filter$)<>0 then
sql$="SELECT * FROM " + tabla$ +" where "+filter$
else
sql$="SELECT * FROM " + tabla$
end if
if len(ord$)>0 then
sql$=sql$+" ORDER BY "+ord$
end if
#sql execute(sql$)
end function
function droptable$(db,ドルtabla$)
if dontclose=0 then sqliteconnect #sql,db$
sql$="drop table "+tabla$
#sql execute(sql$)
if dontclose=0 then #sql disconnect()
end function
function replace$(db,ドルtabla,ドルfilter,ドルwith$)
if dontclose=0 then sqliteconnect #sql,db$
sql$="update "+tabla$+" SET "+with$
if len(filter$) > 0 then sql$=sql$+" where "+filter$
#sql execute(sql$)
if dontclose=0 then #sql disconnect()
end function
function delete$(db,ドルtabla,ドルfilter$)
if dontclose=0 then sqliteconnect #sql,db$
sql$="delete from "+tabla$+" where "+filter$
#sql execute(sql$)
if dontclose=0 then #sql disconnect()
end function
function existable(db,ドルtabla$)
existable=0
#sql execute("SELECT * FROM sqlite_master")
while #sql hasAnswer()
r$ = #sql nextRow$(",")
tablename$ = word$(r,ドル 2, ",")
if tablename$ = tabla$ then existable=1
wend
#sql disconnect()
end function
function showtables(db$)
sqliteconnect #sql,db$
#sql execute("SELECT * FROM sqlite_master")
html "<table border='2' align='center'> <tr><th> DataBase Manager - "+db$+" </th> </tr></table>"
html "<table border='2' align='center'> <tr><th> Select a table or create a new table </th></tr></table>"
html "<table border='2' align='center'>"
j=1
while #sql hasAnswer()
r$ = #sql nextRow$(",")
tablename$ = word$(r,ドル 2, ",")
if mid$(tablename,1,16ドル) <> "sqlite_autoindex" then
if j=6 then
html "<tr> </tr>"
j=1
end if
html "<th>":button #tablename,ドルtablename,ドル[menu1]:html "</th>"
end if
j=j+1
wend
while j > 1 and j <6
html "<th>":print "...";:html "</th>"
j=j+1
wend
html "</table>"
html "<table align='center'> <th>":button #newtable,"New table",[menu1]:html "</th><th>"
button #end,"Return",[start]: html "</th><th>"
button #end,"Exit",[end]:html "</th></table>"
#sql disconnect()
end function
Function altertable$(db,ドルtabla,ドルfielda,ドルoper$)
if dontclose=0 then sqliteconnect #sql,db$
sql$=trim$("alter table "+tabla$+" "+oper$+" "+fielda$)
#sql execute(sql$)
if dontclose=0 then #sql disconnect()
end function
function showcolumn$(t,ドルcolumn$)
g=1
x=1
ms$=""
if len(order$) > 0 then ms$= " Ordered by "+order$
if len(filtra$)> 0 then ms$= ms$+" Filtered by "+filtra$
html "<table border='2' align='center'> <th> COLUMNS in TABLE : "+t$+ms$+"</th></table>"
html "<table border='2' align='center'>"
while len(word$(column,ドルg,",")) > 0
html "<th>":print word$(column,ドルg,",");:html "</th>"
g=g+1
x=x+1
if x=6 then
html "<tr> </tr>"
x=1
end if
wend
while x > 1 and x < 6
html "<th>":print "...";:html "</th>"
x=x+1
wend
end function
Function inputs$(datax,ドルcolumn,ドルtit$)
cls
html "<table border='2' align='center'><th>"+tit$+" </th></table>"
r=1
g=1
html "<table border='2' align='center'>"
while len(word$(column,ドルr,","))<>0
name$=word$(column,ドルr,",")
dat$=wordx$(datax,ドルr,"|")
if dat$="|" then dat$=""
html "<th>"+name$: html "</th><td><input type='text' id='inp"+str$(r)+"' name='field"+str$(r)+"' value='"+dat$+"' /> </td>"
r=r+1
g=g+1
if g=3 then
html "<tr></tr>"
g=1
end if
wend
o$=setfocus$("inp1")
end function
'*********** Seek a Record *******
function seek$(db,ドルtabla,ドルrecord)
a$=use$(db,ドルtabla,ドルorder,ドルfiltra$)
r=1
while r < record
res$= #sql nextrow$(" |")
r=r+1
wend
end function
'*********** Browse a table ************
function browsex$(db,ドルtabla$)
ch1$=""
rows= #sql rowcount()
ch2$=""
if andor$="and" then ch1$="checked"
if andor$="or" then ch2$="checked"
'********* Part 1 *****************************
html "<table border='2' align='center'><th> DataBase Manager - "+tabla$+" </th></table>"
html "<table border='2' align='center'><th>"
button #add,"Add Column",[mfield]: html "</th><th>"
button #drop,"Drop Column",[mfield]:html "</th><th>"
button #c,"Drop Table",[delete]: html "</th><th>"
button #c,"Return",[loop]
button #end,"Exit",[end]:html "</th></table>"
'*****************Part 2 ***********************
html "<table border=1 align='center'> <th>":
button #n,"Order",[order]:Print " ";
button #n,"Filter",[filter]:print
print "and ";:html "<input type='radio' name='group1' value='and' "+ch1$+" />"
print "or ";:html "<input type='radio' name='group1' value='or' "+ch2$+" /></th><th>"
button #a,"PgUp",[pgup]:print " "
print " ";:button #b,"PgDn",[pgdn]:html "</th><th>"
button #a,"Top",[browtop]:print " "
print " ";:button #b,"Bottom",[browbot]:html "</th><th>"
button #vacuum,"Delete all",[browdel]
button #c,"Import Data",[importd]:print " ";
button #c,"Export Data",[exportd]: html "</th><th>"
print "Row(s) on Screen"
html "<input type='text' size='1' name='lenpg' value='"+str$(lenpg)+"' />"
button #g,"Save",[lenpg]:html "</th><tr></tr>"
column$= trim$(#sql COLUMNNAMES$())
r=1
g=1
'***** Display Browse Columns ***************************
html "<table border='1' align='center'>"
html "<th>Row #</th>"
if sele=3 then html "<th>":button #z,"new",[brownew]:button #y,"update",[browse2]: html "</th>"
while len(word$(column,ドルr,","))<>0
name$=word$(column,ドルr,",")
html "<th>"+name$+"</th>"
r=r+1
wend
html "<tr> </tr>"
if browsepg <=0 then
browsepg=int((rows-1)/lenpg+1)
end if
'***** process the pgup and pgdn controls ******
rec=(browsepg-1)*lenpg+1
if rec > rows then rec=1
if rec=0 then rec=1
until=rec+lenpg-1
if until > rows then
until=rows
end if
browsepg=int((rec-1)/lenpg+1)
x$=seek$(db,ドルtabla,ドルrec)
for x=rec to until
x$=trim$(str$(x))
select case sele
case 0
html "<th>":print x$;:html "</th>"
case 1
html "<th>":button #x,ドルx,ドル[sele]:html "</th>"
case 3
html "<th>"+x$+"</th><th>":button #x,ドル"del",[browdel]: html "</th>":
end select
result$ = #sql nextrow$(" |")
result$=result$+"|"
r=1
'*************** Display Data ********************************************
while len(word$(result,ドルr,"|")) <> 0
datax$=trim$(wordx$(result,ドルr,"|"))
tam=len(datax$)
if tam=0 then tam=5
if sele <> 3 then
html "<td>"+datax$+ "</td>"
else
n$="name/"+str$(x)+"/"+str$(r)
html "<td><input type='text' id='"+n$+"' size='"+str$(tam)+"' name='"+n$+"' value='"+datax$+"' /></td>"
end if
r=r+1
wend
html "<tr> </tr>"
next x
html "</table>"
#sql disconnect()
end function
'******* Function wordx$ ************************
function wordx$(string,ドルpos,char$)
if mid$(string,ドルlen(string$),1)<> char$ then string$=string$+char$
j=1
g=1
for i=1 to pos
j=g
x=instr(string,ドルchar,ドルg)
if x = 0 then exit for
g=x+len(char$)
next i
if x=0 then
wordx$=""
else
wordx$= mid$(string,ドルj,x-j)
end if
end function
'********** Function Set focus ***************
function setfocus$(name$)
html "<script
type='text/javascript'
language='javascript'>
document.getElementById('"+name$+"').focus();
</script>"
end function
'******* Function Alert ********
function alerta$(m$)
html "<script language='javascript' type='text/javascript'>
alert('"+m$+"'); </script>"
end function