DEFINE VARIABLE filen AS CHARACTER NO-UNDO FORMAT "x(8)"
LABEL "Schema Cache Name". DEFINE VARIABLE icnt AS INTEGER NO-UNDO. DEFINE VARIABLE db-table AS CHARACTER LABEL "Select Tables" VIEW-AS SELECTION-LIST MULTIPLE NO-DRAG SIZE 32 BY 7 LIST-ITEMS "customer", "invoice", "item", "localdefault", "order", "orderline", "refcall", "salesrep", "state". DEFINE BUTTON bsave LABEL "Save to File". DEFINE BUTTON bcancel LABEL "Cancel". DEFINE FRAME SchemaFrame SPACE(1) db-table VALIDATE(db-table <> "" AND db-table <> ?, "You must select a table.") filen VALIDATE(filen <> "" AND filen <> ?, "You must enter filename.") SKIP(1) SPACE(20) bsave bcancel WITH TITLE "Save Schema Cache File" SIDE-LABELS SIZE 80 by 11. ON CHOOSE OF bcancel IN FRAME SchemaFrame QUIT. ON CHOOSE OF bsave IN FRAME SchemaFrame DO: ASSIGN filen db-table. IF NOT filen:VALIDATE() THEN RETURN NO-APPLY. IF NOT db-table:VALIDATE() THEN RETURN NO-APPLY. DO WHILE NOT CONNECTED("sports2000"): BELL. PAUSE MESSAGE "When ready to connect the sports2000 database, press <RETURN>". CONNECT sports2000 -1 NO-ERROR. IF NOT CONNECTED("sports2000") THEN DO icnt = 1 to ERROR-STATUS:NUM-MESSAGES: MESSAGE ERROR-STATUS:GET-MESSAGE(icnt). END. ELSE MESSAGE "Sports2000 database connected.". END. RUN i-schcs2.p (INPUT db-table, INPUT filen). DISCONNECT sports2000 NO-ERROR. END. /* ON CHOOSE OF bsave */ ENABLE ALL WITH FRAME SchemaFrame. WAIT-FOR CHOOSE OF bcancel IN FRAME SchemaFrame. |
DEFINE INPUT PARAMETER db-table AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER filen AS CHARACTER NO-UNDO. DEFINE VARIABLE iTab AS INTEGER NO-UNDO. Table-Add: DO iTab = 1 to NUM-ENTRIES(db-table): CASE ENTRY(iTab, db-table): WHEN "customer" THEN FIND FIRST Customer NO-ERROR. WHEN "invoice" THEN FIND FIRST Invoice NO-ERROR. WHEN "item" THEN FIND FIRST Item dO-ERROR. WHEN "localdefault" THEN FIND FIRST LocalDefault NO-ERROR. WHEN "order" THEN FIND FIRST Order NO-ERROR. WHEN "orderline" THEN FIND FIRST OrderLine NO-ERROR. WHEN "refcall" THEN FIND FIRST RefCall NO-ERROR. WHEN "salesrep" THEN FIND FIRST SalesRep NO-ERROR. WHEN "state" THEN FIND FIRST State NO-ERROR. OTHERWISE LEAVE Table-Add. END CASE. END. SAVE CACHE CURRENT sports2000 TO VALUE(filen + ".csh") NO-ERROR. IF NOT ERROR-STATUS:ERROR THEN MESSAGE "Saved partial schema cache for the sports2000 database in " + filen + ".csh.". ELSE DO: BELL. DO iTab = 1 TO ERROR-STATUS:NUM-MESSAGES: MESSAGE ERROR-STATUS:GET-MESSAGE(iTab) VIEW-AS ALERT-BOX. END. END. |