/******************************************************************************* Module Template Client part Version: 1.0 Authors: Sebastien DENEUX & Julien Zorko Last update: 28/02/2001 Template Module *******************************************************************************/ /******************************************************************************* * All the global variables are grouped in a structure. * Some message boxes are in comment in the callback functions in order to see exactly when these callback are called. *******************************************************************************/ typeof WINDOW = ObjWin ;; typeof label = ObjText ;; typeof labeld = ObjText ;; typeof oText = ObjText ;; typeof BtnLoad = ObjButton ;; typeof BtnSave = ObjButton ;; typeof DownLoad = ObjButton ;; typeof currentTag = Tag ;; typeof SQLreq = S ;; typeof distinct = I ;; /******************************************************************************* open the admistration interface from -> DMI : not used user -> User : the user that run the action action -> S : not used param -> S : not used others -> [User r1] : not used tag -> Tag : not used <- I : nothing special *******************************************************************************/ fun cbHide (from, action, param, others, tag) = _SHOWwindow WINDOW WINDOW_HIDDEN; _DMSeventTag this "hidden" nil nil nil; 0 ;; fun list_attr_to_string(list, param)= if list == nil then nil else if (listlength list) == 1 then strcatn param::(hd hd list)::nil else strcatn param::(hd hd list)::", "::(list_attr_to_string tl list param)::nil ;; fun _SendSQL (btn, Myuser) = _DMSreplyTag currentTag strcatn SQLreq::" "::(_GETtext oText)::nil Myuser 0; _DMStagForget currentTag; set currentTag = nil; _SHOWwindow WINDOW WINDOW_HIDDEN ;; /******************************************************************************* open the admistration interface from -> DMI : not used user -> User : the user that run the action action -> S : not used param -> S : not used others -> [User r1] : not used tag -> Tag : not used <- I : nothing special *******************************************************************************/ fun cbShow (from, action, param, others, tag) = _CBbutton DownLoad @_SendSQL others; if (!strcmp param "error") then 0 else let strextr param -> list in let hd hd list -> table in let tl list -> list_Attr in let if distinct then "SELECT DISTINCT " else "SELECT " -> tmp in let if !strcmp table "#MySqlReq#" then linebuild hd tl list else strcatn tmp::(list_attr_to_string list_Attr (strcatn " "::table::"."::nil))::" FROM "::table::nil -> SQLtmp in let strcatn (_loc this "DB_SPEACHDEB" nil)::"\n\n"::SQLtmp::nil -> tmplabel in ( set SQLreq = SQLtmp; _SETtext label tmplabel; _SETtext oText ""; 0 ); _DMStagKeepAlive tag; set currentTag = tag; _SHOWwindow WINDOW WINDOW_UNHIDDEN; _DMSeventTag this "shown" nil nil nil; 0 ;; fun _load (Box, param, Fichier)= _SETtext oText (_getpack Fichier) ;; fun _LoadSQL (btn, param) = _DLGrflopen _DLGOpenFile _channel WINDOW "" "Load" "SQL\0*.sql\0All\0*.*\0\0" @_load nil ;; fun _SAVE(save, param, path)= let _GetFileNameFromW path -> name in _storepack (_GETtext oText) name ;; fun _SaveSQL (btn, param) = _DLGrflsave _DLGSaveFile _channel WINDOW "" "Save" "SQL\0*.sql\0All\0*.*\0\0" @_SAVE nil ;; fun _reSize(win, param, newWidth, newHeight)= let (if newWidth > 400 then newWidth else 400) -> Width in let (if newHeight > 400 then newHeight else 400) -> Height in let 5 -> step in let Width-10 -> Llabel in let Height/5 -> Htext in let 7*Height/10 -> Hlabel in let 25 -> Hbtn in let Width/5 -> Lbtn in ( _SIZEtext label Llabel Hlabel-20 step 0; _SIZEtext oText Llabel Htext step Hlabel; _SIZEtext labeld Llabel 20 step Hlabel-20; _SIZEbutton BtnLoad Lbtn Hbtn step Htext+Hlabel+10; _SIZEbutton BtnSave Lbtn Hbtn 2*step+Lbtn Htext+Hlabel+10 ; _SIZEbutton DownLoad Lbtn Hbtn 3*step+2*Lbtn Htext+Hlabel+10 ) ;; fun _close(win, param)= _DMSeventTag this "hidden" nil nil nil; _SHOWwindow win WINDOW_HIDDEN ;; fun CreateInterface()= let 400 -> Hwin in let 600 -> Lwin in let 5 -> step in let Lwin-10 -> Llabel in let Hwin/5 -> Htext in let 7*Hwin/10 -> Hlabel in let 25 -> Hbtn in let Lwin/5 -> Lbtn in ( set WINDOW = _CRwindow _channel nil 500 100 Lwin Hwin WN_MENU|WN_HIDDEN|WN_SIZEBOX "SQL Request" ; set label = _CRtext _channel WINDOW step 0 Llabel Hlabel-20 ET_ALIGN_LEFT ""; set oText = _CReditText _channel WINDOW step Hlabel Llabel Htext ET_ALIGN_LEFT|ET_AVSCROLL|ET_VSCROLL|ET_BORDER|ET_TABFOCUS ""; set labeld = _CRtext _channel WINDOW step Hlabel-20 Llabel 20 ET_ALIGN_LEFT (_loc this "DB_SPEACHFIN" nil); set BtnLoad = _CRbutton _channel WINDOW step Htext+Hlabel+10 Lbtn Hbtn nil (_loc this "DB_LOAD" nil); set BtnSave = _CRbutton _channel WINDOW 2*step+Lbtn Htext+Hlabel+10 Lbtn Hbtn nil (_loc this "DB_SAVE" nil); set DownLoad = _CRbutton _channel WINDOW 3*step+2*Lbtn Htext+Hlabel+10 Lbtn Hbtn nil (_loc this "DB_DOWNLOAD" nil); _CBwinClose WINDOW @_close nil; _CBwinSize WINDOW @_reSize nil; _CBbutton BtnLoad @_LoadSQL nil; _CBbutton BtnSave @_SaveSQL nil; _CBbutton DownLoad @_SendSQL nil ) ;; /******************************************************************************* Global comments about the SCOL file structure parameter -> S : String sent by the server by calling _DMScreateClientDMI <- I : nothing special *******************************************************************************/ fun IniDMI (param) = set distinct = atoi param; CreateInterface ; _DMSdefineActions this (["show" @cbShow]):: (["hide" @cbHide]):: nil; _DMSregister this nil; _DMSeventTag this "in" nil nil nil; 0 ;;