Commit inicial: fuentes MBS ERP (Genero 6) + .gitignore + docs/SETUP_PC_MBS.md

This commit is contained in:
2026-08-18 20:59:52 -04:00
commit 454973e269
5978 changed files with 2664094 additions and 0 deletions
@@ -0,0 +1,239 @@
# Property of Four Js*
# (c) Copyright Four Js 1995, 2019. All Rights Reserved.
# * Trademark of Four Js Development Tools Europe Ltd
# in the United States and elsewhere
#
# Four Js and its suppliers do not warrant or guarantee that these
# samples are accurate and suitable for your purposes. Their inclusion is
# purely for information purposes only.
TYPE schema_rec RECORD
table_name STRING, -- customer
field_name STRING, -- customer_name
field_type SMALLINT, -- 0
field_strtype STRING, -- CHAR(30)
field_length SMALLINT -- 80
END RECORD
DEFINE col_arr DYNAMIC ARRAY OF schema_rec
DEFINE tab_arr DYNAMIC ARRAY OF STRING
DEFINE currtable STRING --current table in combobox
--a(vailable) fields
DEFINE afields DYNAMIC ARRAY OF RECORD
atable STRING,
acol STRING
END RECORD
--c(hosen) fields
DEFINE cfields DYNAMIC ARRAY OF RECORD
ctable STRING,
ccol STRING
END RECORD
-- Current wizard page
DEFINE currpage SMALLINT
DEFINE myd ui.Dialog
CONSTANT TOTAL_PAGES = 5
MAIN
CLOSE WINDOW screen
CALL wizard()
END MAIN
--contains the wizard MD dialog
FUNCTION wizard()
DEFINE i INT
CALL readTables("stores.sch")
OPEN WINDOW formwizard WITH FORM "formwizard"
CALL init_tables()
OPTIONS FIELD ORDER FORM
DIALOG ATTRIBUTES(UNBUFFERED)
INPUT BY NAME currtable ATTRIBUTES(WITHOUT DEFAULTS=TRUE)
ON CHANGE currtable
CALL on_change_currtable()
CALL setup(DIALOG)
END INPUT
DISPLAY ARRAY afields TO a.* END DISPLAY
DISPLAY ARRAY cfields TO c.* END DISPLAY
ON ACTION right CALL right(DIALOG)
ON ACTION allright CALL allright(DIALOG)
ON ACTION left CALL left(DIALOG)
ON ACTION allleft CALL allleft(DIALOG)
ON ACTION prevwiz DISPLAY "prevwiz" EXIT DIALOG
ON ACTION nextwiz DISPLAY "nextwiz" EXIT DIALOG
ON ACTION cancel
EXIT DIALOG
ON ACTION accept
ACCEPT DIALOG
BEFORE DIALOG
LET currpage = 1
CALL setup(DIALOG)
AFTER DIALOG
--we just show all chosen columns in the terminal
FOR i=1 TO cfields.getLength()
DISPLAY sfmt("table:%1,column:%2",cfields[i].ctable,cfields[i].ccol)
END FOR
END DIALOG
LET myd=NULL
CLOSE WINDOW formwizard
END FUNCTION
--fill the combobox with all table names
FUNCTION init_tables()
DEFINE cb ui.ComboBox
DEFINE i INTEGER
LET cb = ui.ComboBox.forName("formonly.currtable")
IF cb IS NULL THEN
CALL myerror("combobox not found")
END IF
FOR i=1 TO tab_arr.getLength()
CALL cb.addItem(tab_arr[i],tab_arr[i])
END FOR
LET currtable=tab_arr[1]
CALL on_change_currtable()
END FUNCTION
--combo value has changed,refill the left array and omit
--values of the right hand side
FUNCTION on_change_currtable()
DEFINE tab,col STRING
DEFINE col_len,used_col_len,idx,i,j,foundUsed INT
IF myd IS NOT NULL THEN
CALL myd.deleteAllRows("a")
ELSE
CALL afields.clear()
END IF
LET idx=0
LET col_len=col_arr.getLength()
FOR i=1 TO col_len
LET tab=col_arr[i].table_name
LET col=col_arr[i].field_name
LET used_col_len=cfields.getLength()
LET foundUsed=FALSE
FOR j=1 TO used_col_len
IF cfields[j].ctable=tab AND cfields[j].ccol=col THEN
LET foundUsed=TRUE
EXIT FOR
END IF
END FOR
IF NOT foundUsed AND tab=currtable THEN
LET idx=idx+1
IF myd IS NOT NULL THEN
CALL myd.appendRow("a")
ELSE
CALL afields.appendElement()
END IF
LET afields[idx].atable=tab
LET afields[idx].acol=col
END IF
END FOR
END FUNCTION
FUNCTION setup(d)
DEFINE d ui.Dialog
DEFINE rl,rr INT
LET myd=d
LET rl = afields.getLength()
LET rr = cfields.getLength()
CALL d.setActionActive("right", rl>0)
CALL d.setActionActive("allright", rl>0)
CALL d.setActionActive("left", rr>0)
CALL d.setActionActive("allleft", rr>0)
CALL d.setActionActive("prevwiz", currpage>1)
CALL d.setActionActive("nextwiz", currpage<TOTAL_PAGES)
END FUNCTION
--move the current item to the right hand side and delete it on the left hand side
FUNCTION right(d)
DEFINE d ui.Dialog
DEFINE idx,lastC INT
LET idx = d.getCurrentRow("a")
IF idx<1 THEN RETURN END IF
LET lastC=cfields.getLength()+1
CALL myd.appendRow("c")
LET cfields[lastC].ctable=afields[idx].atable
LET cfields[lastC].ccol=afields[idx].acol
CALL afields.deleteElement(idx)
CALL d.setCurrentRow("c",lastC)
CALL setup(d)
END FUNCTION
--move all items to the right hand side
FUNCTION allright(d)
DEFINE d ui.Dialog
DEFINE lastC,i INT
LET lastC=cfields.getLength()
FOR i=1 TO afields.getLength()
LET lastC=lastC+1
CALL myd.appendRow("c")
LET cfields[lastC].ctable=afields[i].atable
LET cfields[lastC].ccol=afields[i].acol
END FOR
CALL myd.deleteAllRows("a") --CALL afields.clear()
CALL d.setCurrentRow("c",lastC)
CALL setup(d)
END FUNCTION
--remove the current item from the right hand side and refill the left hand side
FUNCTION left(d)
DEFINE d ui.Dialog
DEFINE idx,i INT
DEFINE col, tab STRING
LET idx =d.getCurrentRow("c")
IF idx<1 THEN RETURN END IF
LET tab=cfields[idx].ctable
LET col=cfields[idx].ccol
CALL cfields.deleteElement(idx)
CALL on_change_currtable()
FOR i=1 TO afields.getLength()
IF afields[i].atable=tab AND afields[i].acol=col THEN
CALL d.setCurrentRow("a",i)
EXIT FOR
END IF
END FOR
CALL setup(d)
END FUNCTION
--remove all items from the right hand side and refill the left hand side
FUNCTION allleft(d)
DEFINE d ui.Dialog
CALL cfields.clear()
CALL on_change_currtable()
CALL setup(d)
END FUNCTION
--read in a schema file
FUNCTION readTables(schemaFile)
DEFINE schemaFile STRING
DEFINE ch base.channel
DEFINE prevTabName STRING
DEFINE sch schema_rec
CALL col_arr.clear()
CALL tab_arr.clear()
LET ch = base.channel.create()
WHENEVER ERROR CONTINUE
CALL ch.openFile(schemaFile, "r")
WHENEVER ERROR STOP
IF STATUS!=0 THEN
CALL myerror( "error: could not open schema file '"||schemaFile||"'")
END IF
CALL ch.setdelimiter("^")
LET prevTabName=NULL
WHILE ch.read(sch)
IF sch.table_name.getIndexOf("sys",1)==1 THEN
CONTINUE WHILE
END IF
LET col_arr[col_arr.getLength()+1].* = sch.*
IF prevTabName IS NULL OR sch.table_name <> prevTabName THEN
LET tab_arr[tab_arr.getLength()+1]=sch.table_name
LET prevTabName=sch.table_name
END IF
END WHILE
CALL ch.close()
IF tab_arr.getLength()==0 THEN
CALL myerror("did not find any coluns in "||schemaFile)
END IF
END FUNCTION
FUNCTION myerror(str)
DEFINE str STRING
DISPLAY "ERROR:",str
EXIT PROGRAM 1
END FUNCTION