$IFDEF FRANCAIS
CONST adfile="data\Contacts.txt"
CONST addeffile="data\champs contacts.txt"
$ELSE
CONST adfile="data\Contact Book.txt"
CONST addeffile="data\contact fields.txt"
$ENDIF
DECLARE SUB adinit
DECLARE SUB adnewClic
DECLARE SUB summaryclic
DECLARE SUB findchange
DECLARE SUB adkeydown(key AS WORD, shift AS INTEGER)
DECLARE SUB adupdate
DECLARE SUB combochange(sender AS QCOMBOBOX)
DECLARE SUB filterchange
CONST admarginW=0.06
CONST adsummaryW=0.36
CONST adseparW=0.06
CONST adfieldW=0.52
CONST adVunit=20
CREATE AdPanel AS QPANEL
PARENT=Tab
left=4 : top=28
COLOR=colorfond
visible=false
borderstyle=0 : bevelouter=0 : bevelinner=0
CREATE summary AS QLISTBOX
onclick=summaryclic
END CREATE
CREATE findlabel AS QLABEL
CAPTION=s_Find
alignment=taRightJustify
END CREATE
CREATE find AS QEDIT
onchange=findchange
END CREATE
CREATE filterlabel AS QLABEL
CAPTION=s_Filter
alignment=taRightJustify
END CREATE
CREATE filter AS QCOMBOBOX
onchange=filterchange
END CREATE
CREATE adnew AS QBUTTON
CAPTION=s_New
onclick=adnewClic
END CREATE
END CREATE
CREATE ad AS QSTRINGLIST
duplicates=dupAccept
END CREATE
DIM adfieldlist AS QSTRINGLIST
CREATE adsummarydesc AS QSTRINGLIST
duplicates=dupError
END CREATE
CREATE hiddensummary AS QSTRINGLIST
duplicates=dupAccept
END CREATE
DIM adfield(0) AS QEDIT
DIM admulti(0) AS QRICHEDIT
DIM adcombo(0) AS QCOMBOBOX
DIM adfieldlabel(0) AS QLABEL
DIM admultilabel(0) AS QLABEL
DIM adcombolabel(0) AS QLABEL
DEFINT nbadfield=0
DEFINT nbadmulti=0
DEFINT nbadcombo=0
DEFINT nbadallfield=0
SUB buildadfields
DIM s AS STRING, key AS STRING, arg AS STRING, s2 AS STRING
DIM thisfield AS STRING, thisfieldtype AS STRING, fieldtypetag AS STRING
DIM filterlist AS QSTRINGLIST
defaultfiltervalue=-1
CHDIR appdir
filterlist.clear
IF FILEEXISTS(adDefFile)=false THEN
adfieldlist.clear
adfieldlist.additems("field"+CHR$(9)+"Info")
adfieldlist.additems("summary"+CHR$(9)+"$Info")
adfieldlist.savetofile(adDefFile)
END IF
adfieldlist.loadfromfile(adDefFile)
x=0 : y=3
FOR i=adfieldlist.itemcount-1 TO 0 STEP -1
s=adfieldlist.item(i)
IF LTRIM$(s)="" THEN
adfieldlist.delitems(i)
ELSEIF LEFT$(s,1)="'" THEN
adfieldlist.delitems(i)
END IF
NEXT
FOR i=0 TO adfieldlist.itemcount-1
s=adfieldlist.item(i)
key=LCASE$(FIELD$(s,CHR$(9),1)) : arg=FIELD$(s,CHR$(9),2)
IF LEFT$(key,5)="multi" THEN key="multi"
SELECT CASE key
CASE "field","champ"
adfieldlist.item(i)=s+CHR$(9)+STR$(nbadfield)+CHR$(9)+STR$(nbadallfield)
REDIM adfieldlabel(nbadfield) AS QLABEL
adfieldlabel(nbadfield).PARENT=adPanel
adfieldlabel(nbadfield).hint=STR$(0.44+x*0.28)+" "+STR$(y)
adfieldlabel(nbadfield).CAPTION=arg
REDIM adfield(nbadfield) AS QEDIT
adfield(nbadfield).PARENT=adPanel
adfield(nbadfield).onchange=adupdate
adfield(nbadfield).hint=STR$(0.44+x*0.28)+" "+STR$(y+1)
IF x=0 THEN
x=1
ELSE
x=0 : y=y+2.5
END IF
nbadallfield++
nbadfield++
CASE "multi"
adfieldlist.item(i)=s+CHR$(9)+STR$(nbadmulti)+CHR$(9)+STR$(nbadallfield)
IF x=1 THEN
x=0 : y=y+2.5
END IF
multinblines=VAL(MID$(s,6,1))
REDIM admultilabel(nbadmulti) AS QLABEL
admultilabel(nbadmulti).PARENT=adPanel
admultilabel(nbadmulti).hint=STR$(0.44+x*0.28)+" "+STR$(y)
admultilabel(nbadmulti).CAPTION=arg
REDIM admulti(nbadmulti) AS QRICHEDIT
admulti(nbadmulti).PARENT=adPanel
admulti(nbadmulti).onchange=adupdate
admulti(nbadmulti).hint=STR$(0.44+x*0.28)+" "+STR$(y+1)+" "+STR$(multinblines)
x=0 : y=y+1.5+multinblines
nbadallfield++
nbadmulti++
CASE "combo"
adfieldlist.item(i)=s+CHR$(9)+STR$(nbadcombo)+CHR$(9)+STR$(nbadallfield)
REDIM adcombolabel(nbadcombo) AS QLABEL
adcombolabel(nbadcombo).PARENT=adPanel
adcombolabel(nbadcombo).hint=STR$(0.44+x*0.28)+" "+STR$(y)
adcombolabel(nbadcombo).CAPTION=arg
REDIM adcombo(nbadcombo) AS QCOMBOBOX
adcombo(nbadcombo).PARENT=adPanel
adcombo(nbadcombo).tag=nbadallfield
adcombo(nbadcombo).onchange=combochange
adcombo(nbadcombo).hint=STR$(0.44+x*0.28)+" "+STR$(y+1)
IF x=0 THEN
x=1
ELSE
x=0 : y=y+2.5
END IF
nbadallfield++
nbadcombo++
CASE "summary","résumé"
flag=true
arg=LCASE$(arg)
WHILE flag
dollarpos=INSTR(arg,"$")
IF dollarpos=0 THEN
adsummarydesc.additems(arg) : flag=false
ELSE
adsummarydesc.additems(LEFT$(arg,dollarpos-1))
arg=RIGHT$(arg,LEN(arg)+1-dollarpos)
FOR j=0 TO i-1
s2=adfieldlist.item(j)
thisfield=LCASE$(FIELD$(s2,CHR$(9),2))
thisfieldlength=LEN(thisfield)
IF MID$(arg,2,thisfieldlength)=thisfield THEN
thisfieldindex=VAL(FIELD$(s2,CHR$(9),4))
thisfieldtype=LCASE$(LEFT$(s2,5))
fieldtypetag="$"
adsummarydesc.additems(fieldtypetag+STR$(thisfieldindex))
arg=RIGHT$(arg,LEN(arg)-thisfieldlength-1)
j=i
END IF
NEXT
END IF
WEND
CASE "filter","filtre"
IF arg="[[def]]" THEN
defaultfiltervalue=VAL(FIELD$(s,CHR$(9),3))
ELSE
filterlist.additems(arg)
END IF
CASE ELSE
FOR j=0 TO nbadallfield-1
s2=adfieldlist.item(j)
thisfield=LCASE$(FIELD$(s2,CHR$(9),2))
thisfieldtype=LCASE$(LEFT$(s2,5))
IF (thisfield=key) AND (thisfieldtype="combo") THEN
thisfieldindex=VAL(FIELD$(s2,CHR$(9),3))
adcombo(thisfieldindex).additems(arg)
END IF
NEXT
END SELECT
NEXT
filter.clear
IF nbadcombo<>0 THEN
FOR i=0 TO adcombo(0).itemcount-1
filter.additems(" "+adcombo(0).item(i))
NEXT
IF filter.item(filter.itemcount-1)<> s_filterOthers THEN filter.additems(s_filterOthers)
filter.additems(s_filterAll)
filter.additems(s_filterOnlythis)
FOR i=0 TO filter.itemcount-3
s=LTRIM$(filter.item(i))
IF filterlist.indexof(s)>=0 THEN
filter.item(i)=" "+s
ELSE
filter.item(i)=" "+s
END IF
NEXT
END IF
filter.itemindex=defaultfiltervalue
FOR i=0 TO nbadcombo-1
adcombo(i).additems(s_additemtocombo, s_deletecomboitem)
NEXT
END SUB
FUNCTION adgetindex(i AS INTEGER) AS INTEGER
adgetindex=VAL(FIELD$(hiddensummary.item(i),separ,2))
END FUNCTION
SUB setfield(fnum AS INTEGER, s AS STRING)
DIM fielddesc AS STRING, fieldtype AS STRING
fielddesc=adfieldlist.item(fnum)
fieldtype=FIELD$(fielddesc,CHR$(9),1)
fieldtype=LCASE$(LEFT$(fieldtype,5))
fieldnum=VAL(FIELD$(fielddesc,CHR$(9),3))
SELECT CASE fieldtype
CASE "champ","field"
adfield(fieldnum).text=s
CASE "multi"
admulti(fieldnum).text=s
CASE "combo"
adcombo(fieldnum).text=s
END SELECT
END SUB
FUNCTION getfield(fnum AS INTEGER) AS STRING
DIM s AS STRING
DIM fielddesc AS STRING, fieldtype AS STRING
fielddesc=adfieldlist.item(fnum)
fieldtype=FIELD$(fielddesc,CHR$(9),1)
fieldtype=LCASE$(LEFT$(fieldtype,5))
fieldnum=VAL(FIELD$(fielddesc,CHR$(9),3))
SELECT CASE fieldtype
CASE "champ","field"
s=adfield(fieldnum).text
CASE "multi"
s=admulti(fieldnum).text
CASE "combo"
s=adcombo(fieldnum).text
END SELECT
getfield=s
END FUNCTION
DEFINT showingcurrentad=false
SUB showcurrentad
DIM record AS STRING, segment AS STRING
showingcurrentad=true
currentad=summary.itemindex
adindex=VAL(FIELD$(hiddensummary.item(currentad),separ,2))
record=ad.item(adindex)
FOR i=0 TO nbadallfield-1
segment=FIELD$(record,CHR$(9),i+1)
setfield(i,segment)
NEXT i
showingcurrentad=false
END SUB
FUNCTION summarystr(record AS STRING) AS STRING
DIM s AS STRING, ss AS STRING
ss=""
FOR i=0 TO adsummarydesc.itemcount-1
s=adsummarydesc.item(i)
IF LEFT$(s,1)="$" THEN
ss=ss+FIELD$(record,CHR$(9),VAL(RIGHT$(s,LEN(s)-1))+1)
ELSE
ss=ss+s
END IF
NEXT
summarystr=ss
END FUNCTION
SUB buildsummary
DIM record AS STRING, lrecord AS STRING, searchstring AS STRING
DIM ss AS STRING, filterStr AS STRING, state AS STRING, filterfield AS STRING
summary.clear
hiddensummary.clear
searchstring=LCASE$(find.text)
filterfieldnum=adcombo(0).tag+1
IF ad.itemcount=0 THEN ad.additems(STRING$(nbadallfield,CHR$(9)))
FOR i=0 TO ad.itemcount-1
record=ad.item(i)
IF record="[[deleted]]" THEN GOTO buildsumnext
lrecord=LCASE$(record)
IF (find.text="") OR (INSTR(lrecord,searchstring)<>0) THEN
showit=false
belongstoacat=false
filterfield=LCASE$(FIELD$(record,CHR$(9),filterfieldnum))
FOR j=0 TO filter.itemcount-4
filterStr=filter.item(j)
state=LEFT$(filterStr,2)
filterStr=LCASE$(MID$(filterStr,3,LEN(filterStr)-2))
IF filterfield=filterStr THEN
belongstoacat=true
IF state<>" " THEN showit=true
END IF
NEXT
IF belongstoacat=false THEN
filterStr=filter.item(filter.itemcount-3)
state=LEFT$(filterStr,2)
showit=IIF(state=" ",false,true)
END IF
IF showit THEN
ss=summarystr(record)
ss=REPLACESUBSTR$(ss,separ," # ")
hiddensummary.additems(ss+separ+STR$(i))
END IF
END IF
buildsumnext:
NEXT
hiddensummary.sort
FOR i=0 TO hiddensummary.itemcount-1
summary.additems(FIELD$(hiddensummary.item(i),separ,1))
NEXT
summary.itemindex=0
showcurrentad
adupdate
END SUB
SUB adinit
DIM s AS STRING
adpanel.width=panelwidth: adpanel.height=panelheight
WITH summary
.left=panelwidth*admarginW/3
.top=3*adVunit
.width=panelwidth*adsummaryW
.height=panelheight-summary.top-3*adVunit
END WITH
WITH findlabel
.left=summary.left : .top=adVunit
.width=summary.width * 0.2 : .height=adVunit
END WITH
WITH find
.left=summary.left+findlabel.width : .top=adVunit
.width=summary.width * 0.4 : .height=adVunit
END WITH
WITH filterlabel
.left=summary.left : .top=summary.top+summary.height+adVunit
.width=summary.width * 0.2 : .height=adVunit
END WITH
WITH filter
.left=summary.left+findlabel.width : .top=filterlabel.top
.width=summary.width * 0.4 : .height=adVunit
END WITH
WITH adnew
.left=summary.left+summary.width*0.7 : .top=adVunit
.width=summary.width * 0.3 : .height=adVunit
END WITH
FOR i=0 TO nbadfield-1
s=adfieldlabel(i).hint
x=VAL(FIELD$(s," ",1)) : y=VAL(FIELD$(s," ",2))
adfieldlabel(i).left=panelwidth*x : adfieldlabel(i).top=y*adVunit
adfieldlabel(i).width=panelwidth*0.26 : adfieldlabel(i).height=adVunit
s=adfield(i).hint
x=VAL(FIELD$(s," ",1)) : y=VAL(FIELD$(s," ",2))
adfield(i).left=panelwidth*x : adfield(i).top=y*adVunit
adfield(i).width=panelwidth*0.26 : adfield(i).height=adVunit
NEXT
FOR i=0 TO nbadmulti-1
s=admultilabel(i).hint
x=VAL(FIELD$(s," ",1)) : y=VAL(FIELD$(s," ",2))
admultilabel(i).left=panelwidth*x : admultilabel(i).top=y*adVunit
admultilabel(i).width=panelwidth*0.26 : admultilabel(i).height=adVunit
s=admulti(i).hint
x=VAL(FIELD$(s," ",1)) : y=VAL(FIELD$(s," ",2)) : h=VAL(FIELD$(s," ",3))
admulti(i).left=panelwidth*x : admulti(i).top=y*adVunit
admulti(i).width=panelwidth*0.54 : admulti(i).height=adVunit*h
NEXT
FOR i=0 TO nbadcombo-1
s=adcombolabel(i).hint
x=VAL(FIELD$(s," ",1)) : y=VAL(FIELD$(s," ",2))
adcombolabel(i).left=panelwidth*x : adcombolabel(i).top=y*adVunit
adcombolabel(i).width=panelwidth*0.26 : adcombolabel(i).height=adVunit
s=adcombo(i).hint
x=VAL(FIELD$(s," ",1)) : y=VAL(FIELD$(s," ",2))
adcombo(i).left=panelwidth*x : adcombo(i).top=y*adVunit
adcombo(i).width=panelwidth*0.26 : adcombo(i).height=adVunit
NEXT
ad.clear
CHDIR appdir
IF FILEEXISTS(adFile)<>false THEN
ad.loadfromfile(adFile)
FOR i=ad.itemcount-1 TO 0 STEP -1
s=ad.item(i)
IF s="" THEN
ad.delitems(i)
ELSE
s=REPLACESUBSTR$(s,crSubst,crString)
ad.item(i)=s
END IF
NEXT
END IF
buildsummary
fileprint.enabled=false
editnew.enabled=true
edituse.enabled=true
menuicon.enabled=false
editall.enabled=false
editfind.enabled=false
editfindnext.enabled=false
setfocus(find.handle)
END SUB
SUB summaryclic
showcurrentad
END SUB
SUB findchange
buildsummary
END SUB
SUB adupdate
DIM record AS STRING, segment AS STRING, ss AS STRING
IF showingcurrentad THEN EXIT SUB
record=""
FOR i=0 TO nbadallfield-1
segment=getfield(i)
IF i<>0 THEN record=record+CHR$(9)
record=record+segment
NEXT i
currentad=summary.itemindex
adindex=adgetindex(currentad)
ad.item(adindex)=record
ss=summarystr(record)
summary.item(currentad)=ss
hiddensummary.item(currentad)=ss+separ+STR$(adindex)
END SUB
SUB focusfirstfield
DIM h AS LONG
DIM fielddesc AS STRING, fieldtype AS STRING
fielddesc=adfieldlist.item(0)
fieldtype=FIELD$(fielddesc,CHR$(9),1)
fieldtype=LCASE$(LEFT$(fieldtype,5))
SELECT CASE fieldtype
CASE "champ","field"
h=adfield(0).handle
CASE "multi"
h=admulti(0).handle
CASE "combo"
h=adcombo(0).handle
END SELECT
setfocus(h)
END SUB
SUB adnewclic
DIM blankrecord AS STRING, blanksumm AS STRING
blankrecord=STRING$(nbadallfield,CHR$(9))
blanksumm=summarystr(blankrecord)
ad.additems(blankrecord)
summary.insertitem(0,blanksumm)
hiddensummary.insertitem(0,blanksumm+separ+STR$(ad.itemcount-1))
summary.itemindex=0
showcurrentad
focusfirstfield
END SUB
DIM s AS STRING, key AS STRING, comboboxname AS STRING
SUB adsave
ad.sort
FOR i=ad.itemcount-1 TO 0 STEP -1
s=ad.item(i)
IF s="[[deleted]]" THEN
ad.delitems(i)
ELSE
s=REPLACESUBSTR$(s,crString,crSubst)
ad.item(i)=s
END IF
NEXT
CHDIR appdir
ad.savetofile(adFile)
DIM fieldef AS QSTRINGLIST
fieldef.duplicates=dupAccept
fieldef.loadfromfile(adDefFile)
FOR i=0 TO fieldef.itemcount-1
s=fieldef.item(i)
IF LTRIM$(s)="" THEN GOTO nextadsavei
IF LEFT$(s,1)="'" THEN GOTO nextadsavei
key=LCASE$(FIELD$(s,CHR$(9),1))
IF LEFT$(key,5)="multi" THEN GOTO nextadsavei
IF (key="field")OR(key="champ")OR(key="multi")OR(key="combo")OR(key="summary")OR(key="résumé") THEN GOTO nextadsavei
EXIT FOR
nextadsavei:
NEXT
FOR j=i TO fieldef.itemcount-1
fieldef.delitems(i)
NEXT
FOR i=0 TO nbadcombo-1
combofieldnb=adcombo(i).tag
comboboxname=FIELD$(adfieldlist.item(combofieldnb),CHR$(9),2)
FOR j=0 TO adcombo(i).itemcount-3
fieldef.additems(comboboxname+CHR$(9)+adcombo(i).item(j))
NEXT
NEXT
FOR i=0 TO filter.itemcount-3
s=filter.item(i)
IF LEFT$(s,2)=" " THEN fieldef.additems("filtre"+CHR$(9)+s-" ")
NEXT
IF filter.itemindex>=0 THEN fieldef.additems("filtre"+CHR$(9)+"[[def]]"+CHR$(9)+STR$(filter.itemindex))
fieldef.savetofile(adDefFile)
END SUB
DEFINT previouscat=-1
SUB filterchange
DIM s AS STRING, state AS STRING
i=filter.itemindex
SELECT CASE i
CASE filter.itemcount-2
FOR j=0 TO filter.itemcount-3
s=filter.item(j)
s=" "+MID$(s,3,LEN(s)-2)
filter.item(j)=s
previouscat=i
NEXT
CASE filter.itemcount-1
IF (previouscat=-1)OR(previouscat>filter.itemcount-3) THEN EXIT SUB
FOR j=0 TO filter.itemcount-3
s=filter.item(j)
state=IIF(j=previouscat," "," ")
s=state+MID$(s,3,LEN(s)-2)
filter.item(j)=s
NEXT
CASE ELSE
s=filter.item(i)
state=LEFT$(s,2)
state=IIF(state=" "," "," ")
s=state+MID$(s,3,LEN(s)-2)
filter.item(i)=s
previouscat=i
END SELECT
filter.itemindex=previouscat
filter.text=s
buildsummary
END SUB
SUB combochange(sender AS QCOMBOBOX)
DIM previousvalue AS STRING, currentrecord AS STRING
whichfield=sender.tag
whichbox=VAL(FIELD$(adfieldlist.item(whichfield),CHR$(9),3))
currentrecordnb=VAL(FIELD$(hiddensummary.item(summary.itemindex),separ,2))
currentrecord=ad.item(currentrecordnb)
previousvalue=FIELD$(currentrecord,CHR$(9),whichfield+1)
previouscomboindex=-1
FOR i=0 TO adcombo(whichbox).itemcount-1
IF adcombo(whichbox).item(i)=previousvalue THEN previouscomboindex=i
NEXT
itemindexfromend=adcombo(whichbox).itemcount-1-adcombo(whichbox).itemindex
SELECT CASE itemindexfromend
CASE 0
IF previouscomboindex=-1 THEN
SHOWMESSAGE("'"+previousvalue+"' "+s_combodeleteimpossible)
adcombo(whichbox).itemindex=-1
adupdate
ELSEIF MESSAGEDLG(s_combodeleteconfirm+" '"+previousvalue+"' ?", mtWarning, mbYes OR mbNo, 0) = mrYes THEN
adcombo(whichbox).delitems(previouscomboindex)
adcombo(whichbox).itemindex=-1
IF whichbox=0 THEN filter.delitems(previouscomboindex)
adupdate
ELSE
adcombo(whichbox).itemindex=previouscomboindex
END IF
CASE 1
IF previouscomboindex<>-1 THEN
SHOWMESSAGE("'"+previousvalue+"' "+s_comboalreadyexists)
adcombo(whichbox).itemindex=previouscomboindex
ELSE
whereto=adcombo(whichbox).itemcount-2
adcombo(whichbox).insertitem(whereto,previousvalue)
adcombo(whichbox).itemindex=adcombo(whichbox).itemcount-3
IF whichbox=0 THEN filter.insertitem(whereto," "+previousvalue)
END IF
CASE ELSE
adupdate
END SELECT
END SUB
SUB addelete
currentad=summary.itemindex
adindex=adgetindex(currentad)
ad.item(adindex)="[[deleted]]"
hiddensummary.delitems(currentad)
summary.delitems(currentad)
showcurrentad
END SUB
SUB adfindfocus(byref fieldtype AS STRING, byref fieldnum AS INTEGER, byref selecttext AS STRING)
DIM fielddesc AS STRING
DIM h AS LONG
h=getfocus
FOR i=0 TO nbadallfield-1
fielddesc=adfieldlist.item(i)
fieldtype=FIELD$(fielddesc,CHR$(9),1)
fieldtype=LCASE$(LEFT$(fieldtype,5))
fieldnum=VAL(FIELD$(fielddesc,CHR$(9),3))
SELECT CASE fieldtype
CASE "champ","field"
IF adfield(fieldnum).handle=h THEN
selecttext=adfield(fieldnum).seltext
EXIT SUB
END IF
CASE "multi"
IF admulti(fieldnum).handle=h THEN
selecttext=admulti(fieldnum).seltext
EXIT SUB
END IF
END SELECT
NEXT
IF find.handle=h THEN
fieldtype="find"
selecttext=find.seltext
ELSE
fieldtype=""
END IF
END SUB
SUB adcut
IF getfocus=summary.handle THEN
adindex=adgetindex(summary.itemindex)
clipboard.text=ad.item(adindex)
adDelete
EXIT SUB
END IF
DIM selecttext AS STRING, fieldtype AS STRING
DIM fieldnum AS INTEGER
adfindfocus(fieldtype,fieldnum,selecttext)
IF fieldtype="" THEN EXIT SUB
clipboard.text=selecttext
SELECT CASE fieldtype
CASE "champ","field"
adfield(fieldnum).seltext=""
CASE "multi"
admulti(fieldnum).seltext=""
CASE "find"
find.seltext=""
END SELECT
END SUB
SUB adcopy
IF getfocus=summary.handle THEN
adindex=adgetindex(summary.itemindex)
clipboard.text=ad.item(adindex)
EXIT SUB
END IF
DIM selecttext AS STRING, fieldtype AS STRING
DIM fieldnum AS INTEGER
adfindfocus(fieldtype,fieldnum,selecttext)
IF fieldtype="" THEN EXIT SUB
clipboard.text=selecttext
END SUB
SUB adpaste
DIM s AS STRING, summs AS STRING
s=clipboard.text
IF TALLY(s,CHR$(9))=nbadallfield-1 THEN
ad.additems(s)
summs=summarystr(s)
summary.insertitem(0,summs)
summary.itemindex=0
hiddensummary.insertitem(0,summs+separ+STR$(ad.itemcount-1))
showcurrentad
focusfirstfield
ELSE
IF INSTR(s,CHR$(9))<>0 THEN s=FIELD$(s,CHR$(9),1)
DIM selecttext AS STRING, fieldtype AS STRING
DIM fieldnum AS INTEGER
adfindfocus(fieldtype,fieldnum,selecttext)
IF fieldtype="" THEN EXIT SUB
SELECT CASE fieldtype
CASE "champ","field"
adfield(fieldnum).seltext=s
CASE "multi"
admulti(fieldnum).seltext=s
CASE "find"
find.seltext=s
END SELECT
END IF
END SUB
SUB aduse
DIM s AS STRING
DIM selecttext AS STRING, fieldtype AS STRING
DIM fieldnum AS INTEGER
adfindfocus(fieldtype,fieldnum,selecttext)
IF fieldtype="" THEN EXIT SUB
SELECT CASE fieldtype
CASE "champ","field"
s=adfield(fieldnum).seltext
IF s="" THEN
s=adfield(fieldnum).text
adfield(fieldnum).selstart=0
adfield(fieldnum).sellength=LEN(s)
END IF
CASE "find"
s=find.seltext
IF s="" THEN
s=find.text
find.selstart=0
find.sellength=LEN(s)
END IF
CASE "multi"
s=admulti(fieldnum).seltext
IF s="" THEN
s=admulti(fieldnum).line(admulti(fieldnum).wherey)
admulti(fieldnum).selstart=admulti(fieldnum).selstart-admulti(fieldnum).wherex
admulti(fieldnum).sellength=LEN(s)
END IF
END SELECT
use(s)
END SUB
SUB adpageup
index=summary.itemindex
IF index<>0 THEN
summary.itemindex=index-1
showcurrentad
focusfirstfield
END IF
END SUB
SUB adpagedown
index=summary.itemindex
IF index<>summary.itemcount-1 THEN
summary.itemindex=index+1
showcurrentad
focusfirstfield
END IF
END SUB
SUB adkeydown(key AS WORD, shift AS INTEGER)
SELECT CASE key
CASE 13 : adupdate
CASE 33 : adpageup
CASE 34 : adpagedown
END SELECT
END SUB
SUB adprint
SHOWMESSAGE(s_addontprint)
END SUB
|
|