// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // ! This script is provided "as is" by Applied Maths. ! // ! You are free to use and modify this script for your own needs. ! // ! Redistribution or reproduction of the script is prohibited. ! // ! DISCLAIMER: ! // ! Improper use of scripts may corrupt your database. ! // ! Running this script is entirely at your own responsibility. ! // ! Applied Maths accepts no lialibility for any consequences ! // ! resulting from its use. ! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DIALOG dlg; integer usefield[],i,charct,sze,xp,yp,xpmax,ypmax,rs,finished,ok,charcount,size; string fieldname,layoutlist,layoutsel,scemefile,scemefile_list,st,name; FILE fp; finished=0; while not(finished) do { DlgReset(dlg); FileGetList(DbGetPath+"\layoutfiles\*.LYT",st); scemefile_list=""; while length(st)>0 do { scemefile=splitstring(st," "); scemefile_list=scemefile_list+substring(scemefile,1,length(scemefile)-4)+" "; } for i=0 to DbGetFieldCount do { fieldname="key"; if i>0 then fieldname=DbGetFieldName(i); DbGetFieldLayout(fieldname,charct,sze); usefield[i]=0; if (sze>0) and (charct>0) then usefield[i]=1; xp=15+floor((i-1)/10)*150; yp=15+ (i-1 - floor((i-1)/10)*10 )*20; if xpmax0 then fieldname=DbGetFieldName(i); if (usefield[i]=0) then { charct=0;sze=0; if i=0 then sze=1; DbSetFieldLayout(fieldname,charct,sze); } if (usefield[i]=1) then { DbGetFieldLayout(fieldname,charct,sze); if charct=0 then charct=80; if sze<10 then sze=150; DbSetFieldLayout(fieldname,charct,sze); } } } if rs=11 then finished=1; if rs=101 then { if input("Enter a name for this layout:",scemefile) then { ok=FileOpenWrite(fp,DbGetPath+"\layoutfiles\"+scemefile+".lyt"); if not(ok) then { FileCreateDir(DbGetPath+"\layoutfiles"); ok=FileOpenWrite(fp,DbGetPath+"\layoutfiles\"+scemefile+".lyt"); } if not(ok) then message("ERROR: unable to save to this file"); if ok then { for i=1 to DbGetFieldCount do { DbGetFieldLayout(DbGetFieldName(i),charcount,size); FileWrite(fp,DbGetFieldName(i)+" "+str(charcount,0,0)+" "+str(size,0,0)+"~n"); } FileClose(fp); finished=1; } } } if rs=102 then { ok=FileOpenRead(fp,DbGetPath+"\layoutfiles\"+scemefile+".lyt"); if not(ok) then message("ERROR: unable to read this file"); if ok then { while not(FileIsEnd(fp)) do { st=FileRead(fp,999); name=splitstring(st," ");charcount=val(splitstring(st," "));size=val(splitstring(st," ")); if DbGetFieldNr(name)>0 then DbSetFieldLayout(name,charcount,size); } FileClose(fp); finished=1; } } if rs=103 then { if scemefile="" then message("There is no saved layout selected!"); else { DlgReset(dlg); DlgAddText(dlg,"Are you sure you want to delete the saved layout",20,20,300,15); DlgAddText(dlg,"'"+scemefile+"' ?",20,40,200,15); if DlgShow(dlg,"Confirmation",350,180) then FileDelete(DbGetPath+"\layoutfiles\"+scemefile+".lyt"); } } }