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