if file('mbtemptable.dbf') drop table mbtemptable endif if not file('mbtemptable.dbf') create table mbtemptable (name character(20),field_type character(3),field_spec character(10)) endif ** END HEADER -- do not remove this line // // Generated on 2024-02-17 // parameter bModal local f f = new create_n_tableForm() if (bModal) f.mdi = false // ensure not MDI f.readModal() else f.open() endif class create_n_tableForm of FORM with (this) onOpen = class::FORM_ONOPEN height = 25.2727 left = 21.5714 top = 0.2273 width = 79.5714 text = "" endwith this.MBTEMPTABLE1 = new QUERY(this) with (this.MBTEMPTABLE1) width = 10.0 height = 1.0 sql = 'select * from "mbtemptable.DBF"' active = true endwith this.ENTRYFIELD1 = new ENTRYFIELD(this) with (this.ENTRYFIELD1) onKey = class::ENTRYFIELD1_ONKEY height = 1.0 left = 22.0 top = 1.3636 width = 18.4286 value = " " endwith this.PUSHBUTTON1 = new PUSHBUTTON(this) with (this.PUSHBUTTON1) onClick = class::PUSHBUTTON1_ONCLICK height = 1.0909 left = 21.5714 top = 5.6364 width = 15.2857 text = "Continue" endwith this.TEXTLABEL1 = new TEXTLABEL(this) with (this.TEXTLABEL1) height = 1.0 left = 8.7143 top = 1.3636 width = 12.0 text = "Name of table" endwith this.GRID1 = new GRID(this) with (this.GRID1) dataLink = form.mbtemptable1.rowset height = 15.5909 left = 6.5714 top = 7.9091 width = 66.7143 endwith this.PUSHBUTTON2 = new PUSHBUTTON(this) with (this.PUSHBUTTON2) onClick = class::PUSHBUTTON2_ONCLICK height = 1.0909 left = 6.2857 top = 23.9545 width = 15.2857 text = "Create table" endwith this.TEXTLABEL4 = new TEXTLABEL(this) with (this.TEXTLABEL4) height = 1.0 left = 9.0 top = 3.6818 width = 12.0 text = "Default char" endwith this.TEXTLABEL5 = new TEXTLABEL(this) with (this.TEXTLABEL5) height = 1.0 left = 35.4286 top = 3.6818 width = 12.0 text = "Default num" endwith this.ENTRYFIELD4 = new ENTRYFIELD(this) with (this.ENTRYFIELD4) height = 1.0 left = 22.0 top = 3.6818 width = 8.0 value = "15" endwith this.ENTRYFIELD5 = new ENTRYFIELD(this) with (this.ENTRYFIELD5) height = 1.0 left = 48.2857 top = 3.6818 width = 8.0 value = "10,2" endwith this.rowset = this.mbtemptable1.rowset function ENTRYFIELD1_onKey(nChar, nPosition,bShift,bControl) if nChar = 13 form.pushbutton1_onclick() form.grid1.setfocus() elseif nChar = 9 form.pushbutton1_onclick() form.entryfield4.setfocus() endif return function PUSHBUTTON1_onClick use mbtemptable append blank use if type("form.mbtemptable1") # "U" form.mbtemptable1.active = false form.mbtemptable1.active = true endif form.grid1.setfocus() return function PUSHBUTTON2_onClick if "."$form.entryfield1.value form.entryfield1.value = left(form.entryfield1.value,at(".",form.entryfield1.value)-1) endif if empty(form.entryfield1.value) form.entryfield1.value = "mbtesttable" endif cStr= " create table "+form.entryfield1.value+" (" form.rowset.first() cStr += trim(form.rowset.fields["name"].value) cStr += " "+class::convert_type() form.rowset.next() do while not form.rowset.endofset cStr += "," cStr += trim(form.rowset.fields["name"].value) cStr += " "+class::convert_type() form.rowset.next() enddo cStr+= ')' // ?cStr &cStr return function convert_type local cNewtype do case case form.rowset.fields["field_type"].value.toUpperCase() = " " cNewType = "character(" if not empty(form.rowset.fields["field_spec"].value) cNewType += trim(form.rowset.fields["field_spec"].value)+")" else cNewType += form.entryfield4.value + ")" endif case form.rowset.fields["field_type"].value.toUpperCase() = "C" cNewType = "character(" if not empty(form.rowset.fields["field_spec"].value) cNewType += trim(form.rowset.fields["field_spec"].value)+")" else cNewType += form.entryfield4.value + ")" endif case form.rowset.fields["field_type"].value.toUpperCase() = "N" cNewType = "numeric(" if not empty(form.rowset.fields["field_spec"].value) cNewType += trim(form.rowset.fields["field_spec"].value)+")" else cNewType += form.entryfield5.value + ")" endif case form.rowset.fields["field_type"].value.toUpperCase() = "F" cNewType = "float(" if not empty(form.rowset.fields["field_spec"].value) cNewType += trim(form.rowset.fields["field_spec"].value)+")" else cNewType += form.entryfield4.value + ")" endif case form.rowset.fields["field_type"].value.toUppercase() = "I" cNewType ="integer" case form.rowset.fields["field_type"].value.toUpperCase() = "A" cNewType = "autoinc" case form.rowset.fields["field_type"].value.toUpperCase() = "D" cNewType = "date" case form.rowset.fields["field_type"].value.toUpperCase() = "T" cNewType = "timestamp" case form.rowset.fields["field_type"].value.toUpperCase() = "L" cNewtype = "boolean" case form.rowset.fields["field_type"].value.toUpperCase() = "M" cNewtype = "blob(0,1)" case form.rowset.fields["field_type"].value.toUpperCase() = "B" cNewtype = "blob(0,2)" case form.rowset.fields["field_type"].value.toUpperCase() = "O" cNewtype = "blob(0,4)" endcase return cNewType function form_onOpen() return endclass