COD =TDOC_E NUME =Editare Formular/Formule APLIC= EXPL1=Editare Formular/Formule cu editor extern EXPL2= EXPL3= EXPL4= DESCH=D CMD = // modificare formular si formule cu editor extern // varianta MODEL/formular tdoc in XML // Paramaetrii: // -tdoc_param[1] -operatie: V-vizualizare, E-editare, // -tdoc_param[2] -suboperatie "MODEL", "FORMULE", // -tdoc_param[3] -descrierea de model-parametru de intrare/iesire, // completat numai daca tdoc_param[2]="MODEL", altfel NIL // -tdoc_param[4] -descrierea de formule: // -daca tdoc_param[2]="MODEL"-parametru de intrare // vector bidimensional, numai pt.help: // -Cod camp (C), // -Denumire (C), // -Cod camp (C) completat cu "{" la inceput, // sau cu "!" daca lungimea este eronata // si "}" sau "..." la sfirsit. Ex. {xxx..., !xxx }, // -Tip+Lg.Cimp (C), // -Picture (C), // -Caractere separatoare (C), // -Lungime cimp (N) -in conformitate cu lungimea declarate, // -daca tdoc_param[2]="FORMULE"-parametru de intrare/iesire // descrierea completa in forma de sir de caractere, // -tdoc_param[5] -parametru de iesire, important numai in regim de editare: // .T.-operatie executata cu succes, urmeaza sa fie salvata // urmeaza sa fie salvata descrierea de model/formule in functie de suboperatie // -tdoc_param[6] -cale de acces la fisierul de ajutor, optional si la MODEL necompletat, // xx_os := h_OS("l") // daca xml, test, executabil Window sau Linux ? xx_xml := (tdoc_param[2]="MODEL" .AND. '=6 .AND. File(tdoc_param[6]), tdoc_param[6],NIL) // se citesc parametri xx_frm_xml := "WINWORD.EXE /w" xx_frm_ext := "NOTEPAD.EXE" xx_frl_ext := "NOTEPAD.EXE" aSet := {{"FRM_XML",xx_frm_xml}, {"FRM_EXT",xx_frm_ext}, {"FRL_EXT",xx_frl_ext}} #IF ! xparam_sct ("S_PARAM","TIPURI_DOCUMENTE",@aSet) h_MesErr("Citire parametri TIPURI_DOCUMENTE nereusit !", 0) #ENDIF #IF ! xparam_gv (aSet,"FRM_XML",@xx_frm_xml) h_MesErr("Citire parametru FRM_XML nereusit !", 0) #ENDIF #IF ! xparam_gv (aSet,"FRM_EXT",@xx_frm_ext) h_MesErr("Citire parametru FRM_EXT nereusit !", 0) #ENDIF #IF ! xparam_gv (aSet,"FRL_EXT",@xx_frl_ext) h_MesErr("Citire parametru FRL_EXT nereusit !", 0) #ENDIF // construieste textul Formule sForm := "" #IF tdoc_param[2]="MODEL" sForm := "Cod Denumire cimp Lungime Picture CSeparator"+Chr(13)+Chr(10) sForm := sForm + Replicate("-",110)+Chr(13)+Chr(10) // daca MODEL, tdoc_param[4] este matrice AEval(tdoc_param[4], ; {|p| sForm := sForm + h_PadR(p[3],15)+" "+ ; h_Padr(p[2],50)+" "+ ; h_Padr(IIf(Empty(p[4]),"",p[4]), 7)+" "+ ; h_Padr(IIf(Empty(p[5]),"",p[5]),20)+" "+ ; h_Padr(IIf(Empty(p[6]),"",p[6]),10)+" "+ ; IIf(p[7]<=100,"{"+h_Padr(p[1],p[7]-2)+"}","")+Chr(13)+Chr(10)}) #ELSE // daca FORMULE, tdoc_param[4] este string sForm := tdoc_param[4] #ENDIF #IF xx_xml tdoc_param[3] := TdocToXml(tdoc_param[3]) #ENDIF // scrie formular si formule in fisiere #IF tdoc_param[2]="MODEL" // Realizat asa, ca sa nu puna crlf in plus si CtrlZ la sfarsit h_OpenOut(sFModl) h_PutLine(tdoc_param[3],"") h_CloseOut("") #ENDIF h_MemoWrit(sFForm,sForm) xx_cmd := IIF(xx_os="windows_nt","CMD /C START ","START ") cmd_FRL := " "+xx_frl_ext+" " cmd_FRM := " "+IF(xx_xml,xx_frm_xml,xx_frm_ext)+" " #IF tdoc_param[2]="MODEL" #IF "-" $ cmd_FRM .AND. cmd_FRM=cmd_FRL // daca ambele: notepad++.exe -nosession -multiInst #IF xx_os="linux_ts" .or. xx_os="linux_wp" xx_mes := "" #IF ! h_RunhWTools(h_ApplIdnt[2], ; xx_cmd+" /WAIT "+cmd_FRM+h_StPath(sFForm)+" "+h_StPath(sFModl), ; h_ApplIdnt[2]+"- "+xx_cmd+cmd_FRM+" ...",,@xx_mes) h_MesErr(xx_mes, 0) #ENDIF #ELSE h_DOS(xx_cmd+" /WAIT "+cmd_FRM+sFForm+" "+sFModl) #ENDIF #ELSE #IF xx_os="linux_ts" .or. xx_os="linux_wp" xx_mes := "" #IF ! h_RunhWTools(h_ApplIdnt[2], ; xx_cmd+ cmd_FRL+h_StPath(sFForm)+Chr(13)+Chr(10)+ ; xx_cmd+" /WAIT "+cmd_FRM+h_StPath(sFModl), ; h_ApplIdnt[2]+"- "+xx_cmd+cmd_FRM+" ...",,@xx_mes) h_MesErr(xx_mes, 0) #ENDIF #ELSE h_DOS(xx_cmd+ cmd_FRL+sFForm) h_DOS(xx_cmd+" /WAIT "+cmd_FRM+sFModl) #ENDIF #ENDIF #IF tdoc_param[1] = "E" tdoc_param[3] := MemoRead(sFModl) #ENDIF #ELSE #IF ! Empty(sFhlp) .AND. "-" $ cmd_FRM #IF xx_os="linux_ts" .or. xx_os="linux_wp" xx_mes := "" #IF ! h_RunhWTools(h_ApplIdnt[2], ; xx_cmd+" /WAIT "+cmd_FRM+h_StPath(sFhlp)+" "+h_StPath(sFForm), ; h_ApplIdnt[2]+"- "+xx_cmd+cmd_FRM+" ...",,@xx_mes) h_MesErr(xx_mes, 0) #ENDIF #ELSE h_DOS(xx_cmd+" /WAIT "+cmd_FRM+sFhlp+" "+sFForm) #ENDIF #ELSE #IF xx_os="linux_ts" .or. xx_os="linux_wp" xx_mes := "" #IF ! h_RunhWTools(h_ApplIdnt[2], ; IIf(!Empty(sFhlp),xx_cmd+ cmd_FRL+h_StPath(sFhlp)+Chr(13)+Chr(10),"")+ ; xx_cmd+" /WAIT "+cmd_FRL+h_StPath(sFForm), ; h_ApplIdnt[2]+"- "+xx_cmd+cmd_FRL+" ...",,@xx_mes) h_MesErr(xx_mes, 0) #ENDIF #ELSE #IF ! Empty(sFhlp) h_DOS(xx_cmd+ cmd_FRL+sFhlp) #ENDIF h_DOS(xx_cmd+" /WAIT "+cmd_FRL+sFForm) #ENDIF #ENDIF #IF tdoc_param[1] = "E" tdoc_param[4] := MemoRead(sFForm) #ENDIF #ENDIF tdoc_param[5] := .t. // prelucrare XML iniante de memorare #IF xx_xml .AND. tdoc_param[1]="E" tdoc_param[3] := XmlToTdoc(tdoc_param[3]) #ENDIF