|
Post by xxgeek on Apr 14, 2023 17:14:12 GMT
There was a problem with the form NOT closing after the 'write' writes the file and opens the .bas file. As per the help file -R -A should close the JB IDE when the app is closed. Problem was no 'trapclose' command was written to the .bas file. -Fixed I did some editing to add a 'window type' combobox to select one of the window types.. Also added an option combobox to add one of the JB functions. (LB users can make their own And re-aranged the list of comboboxes and remove the statictext that was reporting the current file.(no room, and no need for it, but could be brought back if the window width is increased) If you like the edits keep them, and I / we can work out any bugs. The JB functions don't need to be the combo list. Users could edit the code to point to their own folder of functions. I know I'll be using this Rod, it's quick, and easy to add a window type, and or a JB function. Still may have a bug or 2 though. 'freeform ultra lite v1 '14/04/2023 by rodbird@hotmail.com 'The point of this project is to provide a tool that allows precise 'and easy placement of controls and subsequent adjustment. 'the tool will create a .bas which can be merged into existing code 'if the #handle is amended, use the Edit, Find Replace tool for this
nomainwin global addfastfunction, funcs$, fastfuncs$,upath$ call getUserPath dim windowTypes$(19) windowTypes$(0)= "Window Types":windowTypes$(1)= "dialog":windowTypes$(2)= "dialog_fs":windowTypes$(3)= "dialog_nf":windowTypes$(4)= "dialog_nf_fs" windowTypes$(5)= "":windowTypes$(6)= "dialog_modal":windowTypes$(7)= "dialog_popup":windowTypes$(8)= "graphics" windowTypes$(9)= "graphics_fs":windowTypes$(10) = "graphics_nf":windowTypes$(11)= "graphics_nsb":windowTypes$(12)= "graphics_nsb_nf" windowTypes$(13)= "text":windowTypes$(14)= "text_fs":windowTypes$(15)= "text_nsb":windowTypes$(16)= "text_nsb_ins":windowTypes$(17)= "window" windowTypes$(18)= "window_nf":windowTypes$(19)= "window_popup" dim info$(10,10) dim form$(10) form$(1)="New" form$(2)="Write" form$(3)="Save as" form$(4)="Load" form$(5)="File" dim tool$(14) tool$(1)="StatictText" tool$(2)="TextBox" tool$(3)="ListBox" tool$(5)="ComboBox" tool$(6)="Button" tool$(7)="BmpButton" tool$(8)="GraphicBox" tool$(9)="RadioButton" tool$(10)="CheckBox" tool$(11)="GroupBox" tool$(12)="Menu" tool$(13)="Add New" dim grid$(20) g=1 for n= 5 to 30 step 5 grid$(g)=str$(n) g=g+1 next grid$(g)="Set Grid" grid=10 projectctrh=25 ctrh=25 dim font$(10) font$(1)="Set Control" font$(2)="Reset Ctrl" font$(3)="Set Project" font$(4)="Set Font"'default is Consolas 9" dim v$(100) for n= 1 to 20 v$(n)=str$(n*100) next dim obj(100,6) 'x,y,width/height,type,textheight dim obj$(100,4) 'name,text content,resource,font obj=0 'open the last session file if it exists. files "","lastsession.ffu", info$() If val(info$(0, 0)) > 0 then open "lastsession.ffu" for input as #ses 'on error goto [fail] input #ses, projectname$ input #ses, projectfont$ if projectfont$="" then projectfont$="Consolas 9" input #ses, c$ input #ses, g$ input #ses, w$ input #ses, h$ projectctrh=val(c$) projectgrid=val(g$) grid=projectgrid projectw=val(w$) projecth=val(h$) obj=0 while eof(#ses) = 0 obj=obj+1 line input #ses, l$ obj(obj,1)=val(word$(l$,1,",")) obj(obj,2)=val(word$(l$,2,",")) obj(obj,3)=val(word$(l$,3,",")) obj(obj,4)=val(word$(l$,4,",")) obj(obj,5)=val(word$(l$,5,",")) obj(obj,6)=val(word$(l$,6,",")) line input #ses, obj$(obj,1) line input #ses, obj$(obj,2) line input #ses, obj$(obj,3) line input #ses, obj$(obj,4) if obj(obj,5)=6 then loadbmp obj$(obj,1),obj$(obj,3) if obj(obj,5)=11 then menuset=1 wend goto [success] [fail] projectname$="Untitled" projectfont$="Consolas 9" projectctrh=25 projectgrid=10 projectw=800 projecth=600 redim obj(100,6) 'x,y,width/height,type,textheight redim obj$(100,4) 'name,text content,resource,font obj=0 [success] close #ses else projectname$="Untitled" projectfont$="Consolas 9" projectctrh=25 projectgrid=10 projectw=800 projecth=600 end if
'find out what our pc's client area restrictions are 'first of find out how much space the 'windows theme takes for frame and title WindowWidth=200 WindowHeight=200 open "Measuring" for graphics as #1 #1 "home ; down ; posxy x y" ThemeWidth=WindowWidth-2*x-2 ThemeHeight=WindowHeight-2*y-2 close #1
'open a small properties window and hide it WindowWidth=230 WindowHeight=180 UpperLeftX=(DisplayWidth-230)/2 UpperLeftY=(DisplayHeight-180)/2 statictext #2.st1 "Proj",5,10,30,25 textbox #2.tbproj,45,5,150,25 statictext #2.st2 "Ctrl",5,32,30,25 textbox #2.tbname,45,27,150,25 statictext #2.st3 "Text",5,54,30,25 textbox #2.tbtext,45,49,150,25 statictext #2.st4 "Reso",5,76,30,25 textbox #2.tbreso,45,71,150,25 statictext #2.st5 "Wxyh",5,98,30,25 textbox #2.tbxywh,45,93,150,25 statictext #2.st6 "Font",5,120,30,25 textbox #2.tbfont,45,115,150,25 open "Properties" for window_nf as #2 #2 "font Consolas 9" #2 "trapclose [quit2]" #2.tbproj projectname$ #2.tbxywh "!disable" #2.tbfont "!disable" #2 "hide"
'open the main form window 'this window is resizable, the graphicox will resize but the 'client area, which is a drawn representation of the window 'will only change size if you change the project w/h dimensions WindowWidth=800+ThemeWidth+30 WindowHeight=600+ThemeHeight+45 'gb is offset by 25 UpperLeftX=(DisplayWidth-WindowWidth)/2 UpperLeftY=(DisplayHeight-WindowHeight)/2 combobox #1.form,form$(,[form],5,0,90,30 combobox #1.windowtype,windowTypes$(,[windowType], 100 , 0, 110, 30 combobox #1.tool,tool$(,[tool], 215 ,0, 90 ,30 combobox #1.fastfunctionsList, fastfunctionsList$(), fastfunctionSelected , 310, 0, 130, 45 combobox #1.w,v$(,[formsize],445,0,60,30 combobox #1.h,v$(,[formsize],510,0,60,30 combobox #1.grid,grid$(,[grid],575,0,90,30 combobox #1.font,font$(,[font],670,0,90,30 bmpbutton #1.help,"help.bmp",[help],UL,770,0 graphicbox #1.gb,5,25,830,630 open "Freeform Ultra Lite v1 ";projectname$ for window as #1 #1 "trapclose [quit]" #1 "font Consolas 9" #1 "resizehandler [resize]" #1.windowtype "!Window Type" #1.fastfunctionsList "!Add Function" #1.tool "select Add New" #1.form "select File" #1.grid "select Set Grid" #1.font "select Set Font" #1.w "select ";projectw #1.h "select ";projecth #1.gb "autoresize" #1.gb "vertscrollbar on 0 ";projectw #1.gb "horizscrollbar on 0 ";projecth #1.gb "font ";projectfont$ #1.gb "down ; fill white" #1.gb "place 0 0 ; color 192 255 255 ; backcolor 192 255 255 ; boxfilled ";projectw;" ";projecth #1.gb "color black ; backcolor white" for x= 0 to projectw step grid for y= 0 to projecth step grid #1.gb "set ";x;" ";y next next #1.gb "flush bak" gosub [draw] #1.gb "when rightButtonDown [show]" #1.gb "when leftButtonDown [select]" #1.gb "when characterInput [keys]" #1.gb "setfocus" #2 "show" show=1 #1.windowtype "reload" winType$ = "window" call getfastfunctions wait
[show] if show then #2.tbproj "!contents? t$" projectname$=t$ #2 "hide" show=0 else #2 "show" show=1 end if wait
'the user clicked on the form design window 'either to chose a control or to deselect a control [select] if show then #2 "hide" show=0 #2.tbproj "!contents? t$" projectname$=t$ end if x=MouseX y=MouseY 'before we move on update the currently selected control from properties #2.tbname "!contents? t$" : obj$(selected,1)=lower$(t$) #2.tbtext "!contents? t$" : obj$(selected,2)=t$ #2.tbreso "!contents? t$" : obj$(selected,3)=lower$(t$) 'find the object selected selected=0 action=1 'move 2=expand for n=obj to 1 step -1 if x>obj(n,1) and x<(obj(n,1)+obj(n,3)) and y>obj(n,2) and y<(obj(n,2)+obj(n,4)) then if x>(obj(n,1)+obj(n,3))-grid*2 then action=2 selected=n exit for end if next if selected=0 then #2.tbname "" #2.tbtext "" #2.tbreso "" #2.tbxywh "" #2.tbfont "" end if if selected>0 and action=1 then #1.gb "when leftButtonMove [track]" #1.gb "when leftButtonUp [stop]" offsetX=x-obj(selected,1) offsetY=y-obj(selected,2) end if if selected>0 and action=2 then #1.gb "when leftButtonMove [tracksize]" #1.gb "when leftButtonUp [stopsize]" offsetX=x-(obj(n,1)+obj(n,3)) offsetY=y-(obj(n,2)+obj(n,4)) end if gosub [draw] wait
[track] x=int((MouseX-offsetX+5)/grid)*grid if x<grid then x=grid if x+obj(selected,3)>projectw-grid then x=projectw-grid-obj(selected,3) obj(selected,1)=x y=int((MouseY-offsetY+5)/grid)*grid if y<grid then y=grid if y+obj(selected,4)>projecth-grid then y=projecth-grid-obj(selected,4) obj(selected,2)=y gosub [draw] wait
[stop] #1.gb "when leftButtonMove" #1.gb "when leftButtonUp" gosub [draw] wait
[tracksize] x=int((MouseX-offsetX+5)/grid)*grid if x>projectw-grid then x=projectw-grid if x<obj(selected,1)+grid then x=obj(selected,1)+grid y=int((MouseY-offsetY+5)/grid)*grid if y>projecth-grid then y=projecth-grid if y<obj(selected,2)+ctrh then y=obj(selected,2)+ctrh obj(selected,3)=x-obj(selected,1)'width obj(selected,4)=y-obj(selected,2)'height gosub [draw] wait
[stopsize] #1.gb "when leftButtonMove" #1.gb "when leftButtonUp" action=1 gosub [draw] wait
[keys] k1=asc(right$(Inkey$,1)) k2=asc(left$(Inkey$,1)) 'print k1,k2 if k1=46 then 'delete selected if obj(selected,5)=11 then menuset=0 obj(selected,5)=0 #2.tbname "" #2.tbtext "" #2.tbreso "" #2.tbxywh "" #2.tbfont "" selected=0 gosub [draw] end if if k1=3 then 'copy cpy(1)=obj(selected,1) 'x cpy(2)=obj(selected,2) 'y cpy(3)=obj(selected,3) 'w cpy(4)=obj(selected,4) 'h cpy(5)=obj(selected,5) 'type cpy(6)=obj(selected,6) 'textheight cpy$(1)=obj$(selected,1)'name cpy$(2)=obj$(selected,2)'text content cpy$(3)=obj$(selected,3)'resource array or file path cpy$(4)=obj$(selected,4)'ctrl specific font or "" selected=0 gosub [draw] end if if k1=22 then 'paste if cpy(5)<>0 then obj=obj+1 obj(obj,1)=cpy(1) obj(obj,2)=cpy(2)+cpy(4)+grid cpy(2)=obj(obj,2) obj(obj,3)=cpy(3) obj(obj,4)=cpy(4) obj(obj,5)=cpy(5) obj(obj,6)=cpy(6) obj$(obj,1)=left$(cpy$(1),2);obj obj$(obj,2)=cpy$(2) obj$(obj,3)=cpy$(3) if obj(obj,5)=6 then loadbmp obj$(obj,1),obj$(obj,3) obj$(obj,4)=cpy$(4) selected=obj gosub [draw] end if end if #1.gb "setfocus" wait
[tool] #1.tool "selectionindex? i" cpy(5)=0 select case i case 1 'statictext obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=100 obj(obj,4)=ctrh obj(obj,5)=1 obj$(obj,1)="st";obj obj$(obj,2)="Static text?" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if case 2 'textbox obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=200 obj(obj,4)=ctrh obj(obj,5)=2 obj$(obj,1)="tb";obj obj$(obj,2)="I am a textbox" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if case 3 'listbox obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=200 obj(obj,4)=ctrh*5 obj(obj,5)=3 obj$(obj,1)="lb";obj obj$(obj,2)="Listbox \item2\item3\item4\item5" obj$(obj,3)=obj$(obj,1);"$(" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if case 4 'combobox obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=200 obj(obj,4)=ctrh obj(obj,5)=4 obj$(obj,1)="cb";obj obj$(obj,2)="Combobox \item2\item3\item4\item5" obj$(obj,3)=obj$(obj,1);"$(" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if case 5 'button obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=100 obj(obj,4)=ctrh obj(obj,5)=5 obj$(obj,1)="bt";obj obj$(obj,2)="Button?" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if case 6 'bmp button obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=50 obj(obj,4)=50 obj(obj,5)=6 obj$(obj,1)="bb";obj filedialog "Choose an image","*.bmp",file$ if file$<>"" then open file$ for input as #bmp 'the bmpfileheader bmp$ = Input$(#bmp,lof(#bmp)) obj(obj,3)=value(mid$(bmp$,19,4))'width obj(obj,4)=value(mid$(bmp$,23,4))'height close #bmp loadbmp obj$(obj,1),file$ end if obj$(obj,2)="bmp" obj$(obj,3)=file$ case 7 'graphicbox obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=100 obj(obj,4)=100 obj(obj,5)=7 obj$(obj,1)="gb";obj obj$(obj,2)="I am a graphicbox" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if
case 8 'radiobutton obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=100 obj(obj,4)=ctrh obj(obj,5)=8 obj$(obj,1)="rb";obj obj$(obj,2)="(o) radio?" obj$(obj,3)="" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if case 9 'checkbox obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=100 obj(obj,4)=ctrh obj(obj,5)=9 obj$(obj,1)="cb";obj obj$(obj,2)="[x] check?" obj$(obj,3)="" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if
case 10 'groupbox obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=100 obj(obj,4)=100 obj(obj,5)=10 obj$(obj,1)="gr";obj obj$(obj,2)="Group name?" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if
case 11 'menu if menuset=0 then obj=obj+1 obj(obj,1)=0 obj(obj,2)=0 obj(obj,3)=100 obj(obj,4)=10 obj(obj,5)=11 obj$(obj,1)="mn";obj obj$(obj,2)="Menu Added" menuset=1 end if end select selected=obj gosub [draw] #1.tool "select Add New" #1.gb "setfocus" wait
[form] #1.form "selectionindex? i" select case i case 1 'new gosub [new] case 2 'write gosub [write] case 3 'save as gosub [saveas] case 4 'load goto [load] end select #1.form "select File" gosub [draw] #1.gb "setfocus" wait
[draw] 'clear background to grid image '#1.gb "discard ; drawbmp bak 0 0" #1.gb "discard ; redraw bak" 'redraw the controls for n= 1 to obj 'skip if deleted if obj(n,5)=0 then goto [deleted] 'select which font the control will be drawn with increase control height if necessary if obj$(n,4)="" then #1.gb "font ";projectfont$ ch=projectctrh if obj(n,4)<ch then obj(n,4)=ch else #1.gb "font ";obj$(n,4) ch=obj(n,6) if obj(n,4)<ch then obj(n,4)=ch end if 'if these are menu objects pin to top left if obj(n,5)=11 then obj(n,1)=0 : obj(n,2)=-5 : obj(n,3)=100 : obj(n,4)=10 'if it is selected control change drawing color #1.gb "color black ; backcolor white" if n=selected then if action=1 then #1.gb "color red" if action=2 then #1.gb "color green" 'update the properties textboxes #2.tbname obj$(n,1) #2.tbtext obj$(n,2) #2.tbreso obj$(n,3) #2.tbxywh obj(n,1);" ";obj(n,2);" ";obj(n,3);" ";obj(n,4) if obj$(n,4)="" then #2.tbfont projectfont$;":";obj(n,6) else #2.tbfont obj$(n,4);":";obj(n,6) end if 'if it is a checkbox radiobox or static text make background color transparent if obj(n,5)=1 or obj(n,5)=8 or obj(n,5)=9 or obj(n,5)=10 or obj(n,5)=11 or obj(n,5)=12 then 'if we are expanding make outline color green if n=selected and action=2 then #1.gb "color 0 255 0 ; backcolor 192 255 255" else #1.gb "color 192 192 192 ; backcolor 192 255 255" end if 'now draw the object at desired location #1.gb "place ";obj(n,1);" ";obj(n,2) 'if it is a bmp just draw that if obj(n,5)=6 then #1.gb "drawbmp ";obj$(n,1) else 'draw outline if it is a groupbox all else filled if obj(n,5)=10 then #1.gb "box ";obj(n,1)+obj(n,3);" ";obj(n,2)+obj(n,4) else #1.gb "boxfilled ";obj(n,1)+obj(n,3);" ";obj(n,2)+obj(n,4) end if 'now draw the text in black, or red if control is selected #1.gb "color black " if n=selected then #1.gb "color red" select case obj(n,5) case 5 'centre button text #1.gb "stringwidth? ";"A";" width" xp=(obj(n,3)-width*len(obj$(n,2)))/2 #1.gb "place ";obj(n,1)+xp;" ";obj(n,2)+ch/1.33;" ;\";obj$(n,2) case 10 'groupbox text is offset #1.gb "place ";obj(n,1)+5;" ";obj(n,2)+ch/1.33-ch/2;" ;\";obj$(n,2) case else 'woa! normal left justified text #1.gb "place ";obj(n,1)+5;" ";obj(n,2)+ch/1.33;" ;\";obj$(n,2) end select end if [deleted] next return
[write] 'filedialog "Create .bas",projectname$;".bas",filename$ filename$="test.bas" if filename$<>"" then open filename$ for output as #op 'the header #op "'Project ";projectname$ #op "'Created with Freeform Ultra Lite v1.2 on ";date$() #op "" #op "'Switch off mainwin debugging window" #op "nomainwin" #op "" #op "'Create arrays needed for controls listbox,combobox" for n= 1 to obj if obj(n,5)=3 or obj(n,5)=4 then #op "dim ";obj$(n,3);"10)" #op "for n = 1 to 10" #op " ";obj$(n,3);"n)= str$(n)" #op "next" end if next #op "" #op "'Create controls and open window" #op "WindowWidth = ";projectw+ThemeWidth #op "WindowHeight = ";projecth+ThemeHeight+menuset*projectctrh #op "UpperLeftX = int((DisplayWidth-WindowWidth)/2)" #op "UpperLeftY = int((DisplayHeight-WindowHeight)/2)" if menuset then #op "menu #1, ";chr$(34);"&File";chr$(34);", ";chr$(34);"&Save";chr$(34);", [dummy], ";chr$(34);"&Load";chr$(34);", [dummy]" #op "menu #1, ";chr$(34);"&Color";chr$(34);", ";chr$(34);"&Red";chr$(34);", [dummy], ";chr$(34);"&Green";chr$(34);", [dummy]" #op "menu #1, ";chr$(34);"Size";chr$(34);", ";chr$(34);"Small";chr$(34);", [dummy], ";chr$(34);"Large";chr$(34);", [dummy]" end if
for n=1 to obj select case obj(n,5) case 1 'statictext #op "statictext #1.";obj$(n,1);" ";chr$(34);trim$(obj$(n,2));chr$(34);",";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 2 'textbox #op "textbox #1.";obj$(n,1);",";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 3 'list box #op "listbox #1.";obj$(n,1);",";obj$(n,3);",[";obj$(n,1);"click],";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 4 'combobox #op "combobox #1.";obj$(n,1);",";obj$(n,3);",[";obj$(n,1);"click],";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 5 'button #op "button #1.";obj$(n,1);",";chr$(34);obj$(n,2);chr$(34);",[";obj$(n,1);"click], UL, ";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 6 'bmpbutton #op "bmpbutton #1.";obj$(n,1);",";chr$(34);obj$(n,3);chr$(34);",[";obj$(n,1);"click], UL, ";obj(n,1);",";obj(n,2) case 7 'graphicbox #op "graphicbox #1.";obj$(n,1);",";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 8 'radiobutton #op "radiobutton #1.";obj$(n,1);",";chr$(34);obj$(n,2);chr$(34);",[radio],[radio],";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 9 'checkbox #op "checkbox #1.";obj$(n,1);",";chr$(34);obj$(n,2);chr$(34);",[check],[check],";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 10 'group box #op "groupbox #1.";obj$(n,1);",";chr$(34);obj$(n,2);chr$(34);",";obj(n,1);",";obj(n,2)-5;",";obj(n,3);",";obj(n,4) end select next #op "open ";chr$(34);projectname$;chr$(34);" for ";winType$;" as #1" #op "#1 ";chr$(34);"trapclose [quit]";chr$(34) #op "" #op "'apply any control specific fonts" for n= 1 to obj if obj(n,5)<>0 and obj$(n,4)<>"" then #op "#1.";obj$(n,1);" ";chr$(34);"!font ";obj$(n,4);chr$(34) end if next #op "wait" #op "" #op "'Create the required handlers for each control" #op "'Radiobutton and Checkboxes are given a single handler" check=0 radio=0 for n=1 to obj select case obj(n,5) case 3 'listbox #op "[";obj$(n,1);"click]" #op "'Your handler code here" #op "wait" #op "" case 4 'combobox #op "[";obj$(n,1);"click]" #op "'Your handler code here" #op "wait" #op "" case 5 'button #op "[";obj$(n,1);"click]" #op "'Your handler code here" #op "wait" #op "" case 6 'bmpbutton #op "[";obj$(n,1);"click]" #op "'Your handler code here" #op "wait" #op "" case 8 'radiobutton if radio=0 then #op "[radio]" #op "'Your handler code here" #op "wait" #op "" radio=1 end if case 9 'checkbox if check=0 then #op "[check]" #op "'Your handler code here" #op "wait" #op "" check=1 end if end select next #op "[quit]" #op "close #1" #op "end" close #op call copyFunction end if select case case instr(StartupDir$,"Just BASIC v",1)>1 run chr$(34);StartupDir$;"jbasic.exe";chr$(34);" -R -A ";DefaultDir$;"\";filename$ case instr(StartupDir$,"BASIC Pro v",1)>1 run chr$(34);StartupDir$;"lbpro.exe";chr$(34);" -R -A ";DefaultDir$;"\";filename$ case instr(StartupDir$,"BASIC v",1)>1 run chr$(34);StartupDir$;"liberty.exe";chr$(34);" -R -A ";DefaultDir$;"\";filename$ end select return
[saveas] filedialog "Save As...",projectname$;".ffu",filename$ if filename$<>"" then open filename$ for output as #op filename$=right$(filename$,len(filename$)-len(DefaultDir$)-1) projectname$=left$(filename$,len(filename$)-4) '#1.project "ffu loaded is :";projectname$ #op projectname$ #op projectfont$ #op projectctrh #op projectgrid #op projectw #op projecth for n=1 to obj if obj(n,5)<>0 then #op obj(n,1);","; #op obj(n,2);","; #op obj(n,3);","; #op obj(n,4);","; #op obj(n,5);","; #op obj(n,6) #op obj$(n,1) #op obj$(n,2) #op obj$(n,3) #op obj$(n,4) end if next close #op end if return
[load] filedialog "Open Project...","*.ffu",filename$ if filename$<>"" then open filename$ for input as #ses input #ses, projectname$ '#1.project "ffu loaded is :";projectname$ #2.tbproj projectname$ input #ses, projectfont$ if projectfont$="" then projectfont$="Consolas 9" #1.gb "font ";projectfont$ input #ses, c$ input #ses, g$ input #ses, w$ input #ses, h$ projectctrh=val(c$) projectgrid=val(g$) grid=projectgrid projectw=val(w$) projecth=val(h$) #1.grid "select ";grid #1.w "select ";projectw #1.h "select ";projecth obj=0 while eof(#ses) = 0 obj=obj+1 line input #ses, l$ obj(obj,1)=val(word$(l$,1,",")) obj(obj,2)=val(word$(l$,2,",")) obj(obj,3)=val(word$(l$,3,",")) obj(obj,4)=val(word$(l$,4,",")) obj(obj,5)=val(word$(l$,5,",")) obj(obj,6)=val(word$(l$,6,",")) line input #ses, obj$(obj,1) line input #ses, obj$(obj,2) line input #ses, obj$(obj,3) line input #ses, obj$(obj,4) if obj(obj,5)=6 then loadbmp obj$(obj,1),obj$(obj,3) if obj(obj,5)=11 then menuset=1 wend close #ses end if #1.form "select File" goto [grid]
[new] redim obj(100,6) 'x,y,width/height,type,textheight redim obj$(100,4) 'name,text content,resource,font obj=0 projectname$="Untitled" '#1.project "ffu loaded is :";projectname$ #2.tbproj projectname$ return
[resize] gosub [draw] wait
[formsize] #1.w "contents? w$" #1.h "contents? h$" w=val(w$) h=val(h$) if w=0 or h=0 or (w=projectw and h=projecth) then wait projectw=w projecth=h goto [drawgrid]
[grid] 'resize the grid according to user choice, default is 10 #1.grid "contents? g$" grid=val(g$)
[drawgrid] if grid>0 then projectgrid=grid #1.gb "discard ; fill white" #1.gb "place 0 0 ; color 192 255 255 ; backcolor 192 255 255 ; boxfilled ";projectw;" ";projecth #1.gb "color black ; backcolor white" for x= 0 to projectw step grid for y= 0 to projecth step grid #1.gb "set ";x;" ";y next next #1.gb "flush bak" end if #1.grid "select Set Grid" gosub [draw] #1.gb "setfocus" wait
[font] #1.font "contents? f$" if f$="Set Project" then fontdialog projectfont$,f$ if f$<>"" then projectfont$=f$ #1.gb "font ";projectfont$ #1.gb "place 100 100 ;\Q\Q" #1.gb "posxy x y" projectctrh=(y-100)/2+7 ctrf$=projectfont$ ctrh=projectctrh end if end if if f$="Set Control" then fontdialog projectfont$,f$ if f$<>"" then ctrf$=f$ #1.gb "font ";ctrf$ #1.gb "place 100 100 ;\Q\Q" #1.gb "posxy x y" ctrh=(y-100)/2+7 end if end if if f$="Reset Ctrl" then ctrf$=projectfont$ ctrh=projectctrh end if gosub [draw] #1.font "select Set Font" #1.gb "setfocus" wait
[help] loadbmp "h","helpme.bmp" #1.gb "drawbmp h 0 0 " wait
[windowType] #1.windowtype "contents? winType$" wait
[quit2] playwave "beep" #1.gb "setfocus" 'prevent properties window closing by user wait
[quit] 'save away current session to lastsession.ffu open "lastsession.ffu" for output as #ses #ses projectname$ #ses projectfont$ #ses projectctrh #ses projectgrid #ses projectw #ses projecth for n=1 to obj if obj(n,5)<>0 then #ses obj(n,1);","; #ses obj(n,2);","; #ses obj(n,3);","; #ses obj(n,4);","; #ses obj(n,5);","; #ses obj(n,6) #ses obj$(n,1) #ses obj$(n,2) #ses obj$(n,3) #ses obj$(n,4) end if next close #ses close #2 close #1 end
sub copyFunction x = 0 dim codeLine$(500) if fileExists(upath$;"\AppData\Roaming\Just Basic v2.0\FFFunctions", fastfuncs$) then open upath$;"\AppData\Roaming\Just Basic v2.0\FFFunctions\";fastfuncs$ for input as #fastfunc open DefaultDir$;"\test.bas" for append as #copyfunction #copyfunction "" while eof(#fastfunc) = 0 line input #fastfunc, codeLine$(x) line$ = codeLine$(x) if x < 6 then [skipme] #copyfunction line$ [skipme] x = x + 1 wend close #fastfunc close #copyfunction end if end sub
sub getfastfunctions q$ = chr$(34) dim folderInfo$(1, 1) dim fastfunctionsList$(10) files upath$;"\Application Data\Just Basic v2.0\FFFunctions", folderInfo$() numFiles = val(folderInfo$(0, 0)) redim fastfunctionsList$(numFiles) for x = 1 to numFiles filename$ = folderInfo$(x, 0) if right$(filename$, 3) <> "txt" then [skip] if filename$ = "readme.txt" then [skip] fastfunctionsList$(x) = left$(filename$, len(filename$) - 4) [skip] next x sort fastfunctionsList$(), 0 ,numFiles #1.fastfunctionsList, "reload" end sub
sub fastfunctionSelected fastfunctionsList$ #1.fastfunctionsList, "selection? fastfuncs$" fastfuncs$ = fastfuncs$;".txt" end sub
'get users homepath = aka %userprofile% = "c:\users\xxxxx" (5 characters long normally Win 10) sub getUserPath run "cmd.exe /c echo %userprofile% >UserHomePath.txt", HIDE do scan loop until fileExists(DefaultDir$, "UserHomePath.txt") open "UserHomePath.txt" for input as #1 upath$ = input$(#1, lof(#1)) close #1 if upath$ = "" then notice "Sorry, can't find user path " : end kill DefaultDir$;"\UserHomePath.txt" end sub
'Verify file existence function function fileExists(path$, filename$) dim fileExistsInfo$(0,0) files path$, filename$, fileExistsInfo$() fileExists = val(fileExistsInfo$(0, 0)) 'non zero is true end function
function value(x$) select case len(x$) case 1 value = asc(x$) case 2 value=asc(mid$(x$,1,1)) value=value+(asc(mid$(x$,2,1))*256) case 3 value=asc(mid$(x$,1,1)) value=value+(asc(mid$(x$,2,1))*256) value=value+(asc(mid$(x$,3,1))*65536) case 4 value=asc(mid$(x$,1,1)) value=value+(asc(mid$(x$,2,1))*256) value=value+(asc(mid$(x$,3,1))*65536) value=value+(asc(mid$(x$,4,1))*16777216) end select end function
|
|