** ****************************************************************************************** * **EndUser4gl : Exemple d'un langage de4 génération ** ******************************************************************************************* ** Exemple : SQL ** ***************************************************************************************** global #include "c:\EndUser4gl\4gl\hlp\IncludeSysEU\includesyseu.h" integer : i,x ; char : fileOuput:255 := "c:\EndUser4gl\4gl\hlp\DataFile\outq\SortreportClient.wri", fileWrite:128 := "c:\EndUser4gl\4gl\hlp\datafile\client.txt" ; struct : ref { char code_client: 10 , societe:27 , contact:17 , fonction:25 , adresse:34, ville:12, region:11 ; integer Code_postal ; char pays:13, telephone:15, fax:15; } end_global begin_main SetEnvDataBaseSQL{fox}("c:\EndUser4gl\4gl\hlp\instructionsSql\foxpro\DataBase"); fileopen(1,fileWrite,WRITE) returning (x) ; Message_Return_Code_fileOpenW(x); ** --------------------------------------------------------------------------------- ** ** SELECT and DISPLAY and report ** ** --------------------------------------------------------------------------------- ** ExecuteSQLFetch{fox}( " SELECT * From clients where pays in( 'Canada','Espagne','Danemark') order by pays , code_clien") ForEachRowFind : i++; GetDataColumn: INTO Ref; display " pays : ", ref.pays, " clients : ", ref.CODE_CLIENt," society : ",ref.societe ; fileadd(1,ref) returning (x); End_ForEachRow; fileclose(1); Begin_Report ReportInput "c:\EndUser4gl\4gl\hlp\datafile\client.txt" from ref Reportoutput fileouput level by ref.pays by ref.societe HEADER_REPORT print date column 50, time column 62 ; print " ------------------------------------------------------------------------ "; print " : Entete Etat : "; print " : Liste des Clients ou Vendors by Country/Pays : "; print " ------------------------------------------------------------------------ "; END_HEADER_REPORT HEADER_LEVEL : 01 ** level : 01 ,02,03 etc.. print "*********************************************************************************"; print "*RUPTURE NIVEAU/LEVEL : Country :", Level ,"Key...:", level_key,"Name ..:", ref.pays ; print "*"; print "*" ; print "*********************************************************************************"; END_HEADER_LEVEL DETAIL begin print " Line Détail ....",ref.pays , " town ..",ref.societe ; end_begin ; END_DETAIL BREAK_END_LEVEL : 01 print "--------------------------------------------------------------------------------"; print " Fin de groupe /Level:" level column 2,"total data" column 42,total_level column 60,"Key ", level_key column 75 ; print "--------------------------------------------------------------------------------"; END_BREAK_END_LEVEL End_Report ; SetColorText (HWDISPLAY:blue,white) ; Display " Reporting" ; display ""; SetColorText (HWDISPLAY:yellow,red) ; Display " Sortinput c:\EndUser4gl\4gl\hlp\datafile\client.txt" ; Display " Sortoutput c:\EndUser4gl\4gl\hlp\DataFile\outq\SortreportClient.wri" ; SysCommandWindows("write.exe c:\EndUser4gl\4gl\hlp\DataFile\outq\SortreportClient.wri" ) ; end_main /* ******************************** PROCEDURES *************************************** */ proc Message_Return_Code_fileOpenW(integer u) begin_procedure case_of u when 1 : display " Impossible : read only : file is open by other pgm ",u column 70 ;end_when; when 2 : display " path ou file no exist ",u column 70 ;end_when; otherwise : display " Open Ok " ,u column 60; end_case ; end_procedure