Sommaire |
---|
...
French version / version Française
A french version of this FAQ exists à the following address : https://portal.hardis-group.com/x/gYjWIg
Une version française de cette FAQ existe à l'adresse suivante : https://portal.hardis-group.com/x/gYjWIg
...
Help
To access the online Adelia help , go with your web browser to the address :
...
Bloc de code | ||
---|---|---|
| ||
/* ___ Variables declarations ___________________________________________________________ REF(A5_COD_ARTICLE) w_COD_ARTICLE_1 /* defining the w_COD_ARTICLE_1 as the A5_COD_ARTICLE REF(A5_COD_ARTICLE HL_ART_ALCOOL) w_COD_ARTICLE_2 /* defining the w_COD_ARTICLE_2 as the A5_COD_ARTICLE of the HL_ART_ALCOOL LDM REF(w_COD_ARTICLE_2) w_COD_ARTICLE_3 /* defining the w_COD_ARTICLE_3 as the w_COD_ARTICLE_2 variable /* ___ Lists declarations _______________________________________________________________ LIST LST_ART_ALC_1 *REF_LDM(HL_ART_ALCOOL) /* defining a list with all the properties of the HL_ART_ALCOOL ldm LIST LST_ART_ALC_2 *REF_LDM(HL_ART_ALCOOL) *REF_LDM(HL_ART_LANGUE) /* defining a list with all the properties of the HL_ART_ALCOOL ldm and the HL_ART_LANGUE ldm LIST LST_ART_ALC_3 *REF_LDM(HL_ART_ALCOOL) *REF_LDM(HL_ART_LANGUE) w_COD_ARTICLE_1 /* defining a list with all the properties of the HL_ART_ALCOOL ldm and the HL_ART_LANGUE ldm plus the w_COD_ARTICLE_1 variable |
2 - Size of variables
1 - ALPHA variables
Alpha variables range from 1 to 8386552 .
...
Bloc de code | ||
---|---|---|
| ||
/* ___ Variables declarations ___________________________________________________________ ALPHA( 35) MyVariable1 ALPHA( 2205) MyVariable2 ALPHA( 5K) MyVariable3 ALPHA( 7M) MyVariable4 |
...
2 - NUM_E variables
NUM_E variables are defined with a Total Length value and a decimal value : NUM_E(totalLengthValue, decimalValue)
...
A constant can be used for a displayed text value, an action code value, a return code value, etc.
1 - Definition
To define a new constant, simply go the the L4G editor , Repository menu , Constant dictionary line (or press F9 )
...
- The name should be a representative name for the constant,
- the value is what should replace the constant in the code,
- the "Translatable constant checkbox is used when a constant must be translated (for example for a text value)
2 - Usage
Examples of consant usages :
Bloc de code |
---|
/* ___ Code without constants ___________________________________________________________ if codeAction = 'CR' btn_action:text = 'Create' else btn_action:text = 'Modify' end ... returnCode = 'EX' /* ___ Code with constants ______________________________________________________________ if codeAction = _ACTION_CREATION btn_action:text = _TEXT_CREATE else btn_action:text = _TEXT_MODIFY end ... returnCode = _RETURN_EXIT |
...
Numerical values
1 - Rounded values
To calculate a rounded value , we can use the letter H in front of the = sign.
Without the H operator the result will simply be truncated .
The H character instruction is for "Half adjustment" .
Results in the range 0 to 0.49 will be rounded down to 0 , and results between 0.50 and 0.99 will be rounded up to 1 .
...
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ NUM_E( 3,0) x NUM_E( 3,0) y /* ___ Code _____________________________________________________________________________ x = 2 / 3 /* x will contain 0 y H= 2 / 3 /* y will contain 1 |
2 - Remainder calculation
To retrieves the remainder in a mathematical division we can use the remainder instruction.
The instruction remainder must be placed immediately after the arithmetical expression of the division .
...
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ NUM_E( 3,0) x NUM_E( 3,0) y /* ___ Code _____________________________________________________________________________ x = 10 / 3 /* x will contain 3 remainder y /* y will contain 1 |
3 - Modulo calculation
To calculate the modulo between a numerator and its divisor we can use the &modulo predefined function .
This predefined function can be used instead of the remainder instruction.
...
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ NUM_E( 3,0) x NUM_E( 3,0) y /* ___ Code _____________________________________________________________________________ x = 10 /* x will contain 3 y = &modulo(x;3) /* y will contain 1 |
...
Adelia framework
1 - Visual program
A visual program is constituted with a number of paragraph :
...
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ DECL_PGM /* global variables, DS, lists, cursors, parameters declarations INIT_PGM INITIALIZE WIN_2205 /* call the paragraph to load the data EXECUTE WIN_2205 /* show the window to the user WIN_2205 DECLARATION /* window variables, DS, lists, cursors, parameters declarations INITIALIZATION /* code to execute before displaying the window WORK_WITH_EVENTS OBJECTS_EVENTS... BTN_VALIDATE LeftButtonClick VERIFY /* call the verification paragraph VALIDATE /* call the validation paragraph TERMINATE /* end the window process VERIFICATION /* code to verify the data entered in the window by a user SEND_MSG *CLR_ALL /* clear the error messages if [errorCondition for object ZZ_JLP] prepare_msg hl21734 ZZ_JLP init_msg ZZ_JLP anomaly end ... VALIDATION /* code to store the data in the database after verification UPD_SQL or CREATE_SQL or ... |
...
Procedures
1 - Definition
A procedure is a block of code we can call from inside a program or from outside a program if the procedure is public.
2 - Parameters
3 - Calling a procedure procedure
...
String functions
1 - Concatenate alphanumerical variables
To concatenate two (or more variables) you can use the // or /// operator.
...
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ ALPHA( 10) wLeft ALPHA( 10) wRight ALPHA( 20) wText1 ALPHA( 20) wText2 ALPHA( 20) wText3 /* ___ Code _____________________________________________________________________________ wLeft = 'Hello' wRight = 'World' wText1 = wLeft // wRight /* wText1 = 'Hello World ' wText2 = wLeft /// wRight /* wText2 = 'HelloWorld ' wText3 = wLeft /// ' ' // wRight /* wText3 = 'Hello World ' |
...
3 - Calculate the length of a string
...
In order to split a string into different strings (to a list of strings in reality) according to a separatorcalculate the length of a string, you simply have to use the SPLIT_STRING instruction :the &LONGUEUR_CHAINE predefined function :
Bloc de code |
---|
/* ___ DeclarationsDéclarations _____________________________________________________________________ alpha(num_bin_2 50) elementDay liststringLength alpha(100) lst_days elementDay alpha(1000) myDays /* ___myString /* ___ Code _____________________________________________________________________________ myDaysmyString = 'Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday' split_string myDays ';' lst_days /* the list "lst_days" will contain 7 elements : 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' |
3 - How to replace a part of a string
alpha beta'
stringLength = &longueur_chaine(myString)
/* stringLength value is 10 |
2 - How to split a string according to a separator
In order to split a string into different strings (to a list of strings in reality) according to a separator, you simply have to use the SPLIT_STRING instruction In order to replace a substring in a string, you simply have to use the SCAN_REPLACE instruction :
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ alpha(1000 50) myDays alpha(1000) myDaysModified alpha( 56) mySearchString alpha( 78) myReplacementStringelementDay list lst_days elementDay alpha(1000) myDays /* ___ Code _____________________________________________________________________________ myDays = 'Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday' mySearchString =split_string myDays ';' myReplacementString = ' , ' myDaysModified = *blank scan_replace myDays mySearchString myReplacementString myDaysModified lst_days /* the string myDaysModifiedlist "lst_days" will contain 7 elements : 'Sunday ', 'Monday ', 'Tuesday ', 'Wednesday ', 'Thursday ', 'Friday ', 'Saturday' |
...
3 - How to
...
replace a part of a string
...
In order to
...
In order to add a "return" to an alphanumerical variable, you should create a "CR" (carriage return) + "LF" (line feed) string and add it to your alphanumerical variable.replace a substring in a string, you simply have to use the SCAN_REPLACE instruction :
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ ALPHAalpha( 11000) wCR myDays ALPHAalpha( 11000) wLF myDaysModified ALPHAalpha( 256) wCRLF mySearchString ALPHAalpha(100 78) wText myReplacementString /* ___ Code _____________________________________________________________________________ wCRmyDays = &CHAR_CONVERSION('0D') wLF = &CHAR_CONVERSION('0A') wCRLF = wCR // wLF wText = 'Hello' /// wCRLF /// 'world' z_display = wText |
The multi-line property of the text object should be checked if you want to see the line return.
Date, Time and Timestamp
...
= 'Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday'
mySearchString = ';'
myReplacementString = ' , '
myDaysModified = *blank
scan_replace myDays mySearchString myReplacementString myDaysModified
/* the string myDaysModified will contain 'Sunday , Monday , Tuesday , Wednesday , Thursday , Friday , Saturday' |
4 - How to add a "carriage return" in a string in order to have a return to the line in a screen.
In order to add a "return" to an alphanumerical variable, you should create a "CR" (carriage return) + "LF" (line feed) string and add it to your alphanumerical variable.
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________
ALPHA( 1) wCR
ALPHA( 1) wLF
ALPHA( 2) wCRLF
ALPHA(100) wText
/* ___ Code _____________________________________________________________________________
wCR = &CHAR_CONVERSION('0D')
wLF = &CHAR_CONVERSION('0A')
wCRLF = wCR // wLF
wText = 'Hello' /// wCRLF /// 'world'
z_display = wText |
The multi-line property of the text object should be checked if you want to see the line return.
...
Date, Time and Timestamp
1 - Calculating dates, time and timestamp values
In order to calculate Date, Time and Timestamps, we can use the following functions
- &Calculate_Date
- &Calculate_Time
- &Calculate_Timestamp
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________
date myDate
date myNewDate
time_t MyTime
time_t MyNewTime
timestamp MyTimestamp
timestamp MyNewTimestamp
/* ___ Code _____________________________________________________________________________
myNewDate = &calculate_date(myDate;1;'Y') /* add 1 Year to myDate
myNewDate = &calculate_date(myDate;-6;'M') /* substract 6 Months to myDate
myNewDate = &calculate_date(myDate;40;'D') /* add 40 Days to myDate
myNewTime = &calculate_time(myTime;1;'H') /* add 1 Hours to myTime
myNewTime = &calculate_time(myTime;-6;'M') /* substract 6 Minutes to myTime
myNewTime = &calculate_time(myTime;40;'S') /* add 40 Seconds to myTime
myNewTimestamp = &calculate_tms(myTimestamp;1;'Y ') /* add 1 Year to myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;-6;'M ') /* substract 6 Months myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;40;'D ') /* add 40 Days to myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;1;'H ') /* add 1 Hours to myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;-6;'MI') /* substract 6 Minutes to myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;40;'S ') /* add 40 Seconds to myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;-30;'MS') /* substract 30 Seconds to myTimestamp |
2 - Calculating intervals between dates, time and timestamp values
In order to calculate Dateintervals between Dates, Time Times and Timestamps, we can use the following functions
- &CalculateDate_DateInterval
- &CalculateTime_TimeInterval
- &CalculateTimestamp_TimestampInterval
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ date myDatemyDate1 date myNewDatemyDate2 time_t MyTimemyTime1 time_t MyNewTimemyTime2 timestamp MyTimestampmyTimestamp1 timestamp MyNewTimestampmyTimestamp2 num_e(9,0) myInterval1 num_e(9,0) myInterval2 num_e(15,0) myInterval3 /* ___ Code _____________________________________________________________________________ myNewDatemyInterval1 = &calculatedate_dateinterval(myDate;1;'Y') myDate1;myDate2) /* addnumber of 1days Yearbetween tomyDate1 myDate myNewDateand =myDate2 &calculate_date(myDate;-6;'M') (can be a negative number if myDate1 if greater than myDate2) myInterval2 = &time_interval(myTime1;myTime2) /* substract 6 Months to myDate myNewDate = &calculate_date(myDate;40;'D') /* number of seconds between myTime1 and myTime2 (can be a negative number /*if addmyTime1 40if Daysgreater tothan myDatemyTime2) myNewTimemyInterval3 = &calculatetms_timeinterval(myTimemyTimestamp1;1myTimestamp2;'HY ') /* number of years between myTimestamp1 and myTimestamp2 (can be a negative number /*if addmyTimestamp1 1if Hoursgreater tothan myTimemyTimestamp2) myNewTimemyInterval3 = &calculatetms_timeinterval(myTimemyTimestamp1;-6myTimestamp2;'M ') /* number of months between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 /*if substractgreater 6 Minutes to myTime myNewTimethan myTimestamp2) myInterval3 = &calculatetms_timeinterval(myTimemyTimestamp1;40myTimestamp2;'SD ') /* number of days between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 /*if addgreater 40 Seconds to myTime myNewTimestampthan myTimestamp2) myInterval3 = &calculatetms_tmsinterval(myTimestampmyTimestamp1;1myTimestamp2;'YH ') /* number of hours between myTimestamp1 and myTimestamp2 (can be a negative number /*if addmyTimestamp1 1if Yeargreater tothan myTimestampmyTimestamp2) myNewTimestampmyInterval3 = &calculatetms_tmsinterval(myTimestampmyTimestamp1;-6myTimestamp2;'M MI') /* substractnumber 6of Monthsminutes myTimestamp myNewTimestampbetween = &calculate_tms(myTimestamp;40;'D ') /* add 40 Days to myTimestamp myNewTimestampmyTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2) myInterval3 = &calculatetms_tmsinterval(myTimestampmyTimestamp1;1myTimestamp2;'HS ') /* addnumber 1of Hoursseconds to myTimestamp myNewTimestamp = &calculate_tms(myTimestamp;-6;'MI') /* substract 6 Minutes to myTimestamp myNewTimestamp = &calculate_tms(myTimestamp;40;'S between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2) myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'MS') /* addnumber of 40microseconds Secondsbetween tomyTimestamp1 myTimestamp myNewTimestampand =myTimestamp2 &calculate_tms(myTimestamp;-30;'MS') /* substract 30 Seconds to myTimestamp |
2 - Calculating intervals between dates, time and timestamp values
(can be a negative number if myTimestamp1 if greater than myTimestamp2)
|
3 - Extract informations from a Date variable
In order to extract informations from a Date variableIn order to calculate intervals between Dates, Times and Timestamps, we can use the following functions
- &Date_Interval
- &Time_Interval
- To_Year
- &Date_To_Month
- &Date_To_Day
- &Date_To_Num&Timestamp_Interval
Bloc de code |
---|
/* ___ DeclarationsDéclarations _____________________________________________________________________ date myDate1 date myDate2 time_t myTime1 time_t myTime2 timestamp myTimestamp1 timestamp myTimestamp2 myDate num_e(94,0) myInterval1myYear num_e(92,0) myInterval2myMonth num_e(152,0) myInterval3myDay /* ___ Code _____________________________________________________________________________ myInterval1 = &date_interval(myDate1;myDate2)myYear /* number of days between myDate1 and myDate2 (can be a negative number if myDate1 if greater than myDate2) myInterval2 = &timedate_to_intervalyear(myTime1;myTime2myDate) /* number of seconds between myTime1 and myTime2 (can be a negative number/* ifextract myTime1the ifyear greaterfrom than myTime2) myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'Y ') /* number of years between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2) myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'M ') /* number of months between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2) myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'D ') /* number of days between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2) myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'H ') /* number of hours between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2) myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'MI') /* number of minutes between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2) myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'S ') /* number of seconds between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2) myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'MS') /* number of microseconds between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2) the date myDate (year will be in format CCYY (century + year) myMonth = &date_to_month(myDate) /* extract the month from the date myDate myDay = &date_to_day(myDate) /* extract the day from the date myDate myDateNum = &date_to_num(myDate) /* convert the date myDate to a numerical date (YYYYMMDD format) |
...
Image
1 - Transforming an alpha variable to an image variable
If an image variable should contains a text, it is possible to transform the content of an alpha variable to an image variable in the following way :
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ alpha( 100) fileAlias alpha( 10) fileMode alpha(5000) myAlpha image myImage num_bin_4 nb4ReturnCode /* ___ Code _____________________________________________________________________________ myAlpha = 'my text to be transformed to an image variable (2205) fileAlias = 'myTransformation' fileMode = 'w' load_dll 'VATOOLBX.DLL' call_dll 'VATOOLBX.DLL' 'VaToolBxOpenFile' fileAlias myImage fileMode nb4ReturnCode call_dll 'VATOOLBX.DLL' 'VaToolBxWriteString' fileAlias myAlpha nb4ReturnCode call_dll 'VATOOLBX.DLL' 'VaToolBxCloseFile' fileAlias nb4ReturnCode unload_dll 'VATOOLBX.DLL' /* the myImage variable now contains the alpha text from the myAlpha variable. |
2 - Transforming a image variable to an alpha variable
If an Image variable contains only text, it is possible to transform the Image variable to an alpha variable with the following code :
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ alpha( 100) fileAlias alpha( 10) fileMode num_bin_4 fileSize alpha(5000) myAlpha image myImage num_bin_4 nb4ReturnCode /* ___ Code _____________________________________________________________________________ fileAlias = 'myTransformation' fileMode = 't' fileSize = 5000 load_dll 'VATOOLBX.DLL' call_dll 'VATOOLBX.DLL' 'VaToolBxOpenFile' fileAlias myImage fileMode nb4ReturnCode call_dll 'VATOOLBX.DLL' 'VaToolBxWriteString' fileAlias myAlpha nb4ReturnCode call_dll 'VATOOLBX.DLL' 'VaToolBxReadFile' fileAlias myAlpha fileSize nb4ReturnCode call_dll 'VATOOLBX.DLL' 'VaToolBxCloseFile' fileAlias nb4ReturnCode unload_dll 'VATOOLBX.DLL' /* the myAlpha variable now contains the alpha text from the myImage variable. /* the fileSize contains the real number of characters from the image variable. |
...
Lists
1 - Declarations
A list can be declared with variables , or in reference to a logical entity , or in reference to another list , or a combination of those elements .
Bloc de code |
---|
/* ___ Lists declarations _______________________________________________________________ LIST LST_EXAMPLE ELT_ONE ELT_TWO ELT_2205 /* defining a list with single elements defined previously, here ELT_ONE, ELT_TWO and ELT_2205 variables LIST LST_ART_ALC_2 *REF_LDM(HL_ART_ALCOOL) /* defining a list with all the properties of the HL_ART_ALCOOL ldm LIST LST_ART_ALC_3 *REF_LDM(HL_ART_ALCOOL) *REF_LDM(HL_ART_LANGUE) /* defining a list with all the properties of the HL_ART_ALCOOL ldm and the HL_ART_LANGUE ldm LIST LST_ART_ALC_4 *REF_LDM(HL_ART_ALCOOL) *REF_LDM(HL_ART_LANGUE) w_COD_ARTICLE_1 /* defining a list with all the properties of the HL_ART_ALCOOL ldm and the HL_ART_LANGUE ldm plus the w_COD_ARTICLE_1 variable LIST LST_ART_ALC_5 *REF_L(LST_ART_ALC_4) ELT_2205 /* defining a list with all the properties of the LST_ART_ALC_4 list plus the ELT_2205 variable |
2 - List usage
1 - Add elements
A list is a structured object in memory with columns, it's like a table but in memory.
To insert data in a list, we just have to fill the variables corresponding to the columns of the list, then to add an element to the list.
Elements are by default added at the end of the list (*END), but the also can be added
- at the beginning of the list (INSERT_ELT *BEGIN)
- at the end of the list (INSERT_ELT *END)
- before the current element (INSERT_ELT *BEFORE)
- after the current element (INSERT_ELT *AFTER)
- in the sort order of one (or more) column(s) (INSERT_ELT *SORT(...) )
By default, lines inserted in the list are not considered as modified, but we can tag them as modified when inserted if we want to retrieve later the modified elements. To do this, we can add the *CHANGE tag during the insertion.
...
2 - Parse a list
In order to parse a list , we can use the READ_LST loop.
Inside a parsing loop we are on one element and we can modify it (with CHANGE_ELT) or delete it (with DELETE_ELT)
Bloc de code |
---|
/* ___ Lists usage _______________________________________________________________ READ_LST LST_EXAMPLE /* ELT_ONE is filled with the value of the first line on the first iteration of the list, same for ELT_TWO and ELT_2205 ... IF ... DELETE_ELT LST_EXAMPLE /* we can delete the current element END IF ... ELT_ONE = ELT_ONE + 1 CHANGE_ELT LST_EXAMPLE /* we can change the values of the current element if we modify one (or more) of his columns CHANGE_ELT LST_EXAMPLE *SELECT /* when changing an element we can add the tag SELECTED or UNSELECTED to the element END END_READ_LST /* ___ We can parse for a graphical list the elements selected by the user ______ READ_LST LST_GRAPHICAL *SELECT ... END_READ_LST /* ___ We can parse for a graphical list the elements modified by the user or by a program if it sets the *CHANGE tag during the insertion ___ READ_LST LST_GRAPHICAL *CHANGE ... END_READ_LST |
We can also use more manual loop with READ_F_ELT (read first element) and READ_NX_ELT (read next element).
...
Bloc de code |
---|
/* ___ Lists usage _______________________________________________________________ READ_F_ELT LST_EXAMPLE /* we try to read the first element of the list (if it exists) DO_WHILE &CODE_LST(LST_EXAMPLE) = *NORMAL /* did the last operation on the list end successfully ? ... READ_NX_ELT LST_EXAMPLE /* try to read the next element of the list REDO READ_L_ELT LST_EXAMPLE /* we try to read the last element of the list (if it exists) DO_WHILE &CODE_LST(LST_EXAMPLE) = *NORMAL /* did the last operation on the list end successfully ? ... READ_PR_ELT LST_EXAMPLE /* try to read the next element of the list REDO |
3 - Parse a list using indexes
To parse a list to find an element (or from an element), we can create and use list indexes (with the LIST_INDEX instruction).
Then we will be allowed to use READ_ELT (to read an element) or READ_F_ELEMENT (to go to the first element greater or equal to the value of the index).
...
When an index is not needed more, we can destroy it (to release memory) with the DELETE_INDEX instruction
4 - Operations on lists
To delete a list , we can use the CLEAR_LST instruction,
To copy a list to another list, we can use the COPY_LST instruction,
To insert a list in another list, we can use the INSERT_LST instruction,
To sort a list , we can use the SORT_LST instruction
Bloc de code |
---|
/* ___ Lists usage _______________________________________________________________ CLEAR_LST LST_EXAMPLE /* clear the list specified COPY_LST LST_ONE LST_TWO /* copy the content of the list LST_ONE in the list LST_TWO, /* the two lists are identical at the end of the instruction, /* the two lists must have the same structure INSERT_LST LST_ONE LST_TWO /* add the content of the first list to the second list /* by default the elements are added at the end, but we can specify *BEGIN, *END, *BEFORE, *AFTER INSERT_LST LST_ONE LST_TWO *BEGIN /* add the content of the first list at the start of the second list INSERT_LST LST_ONE LST_TWO *END /* add the content of the first list at the end of the second list INSERT_LST LST_ONE LST_TWO *BEFORE /* add the content of the first list just before the current element of the second list INSERT_LST LST_ONE LST_TWO *AFTER /* add the content of the first list just before the current element of the second list SORT_LST LST_EXAMPLE ELT_2205 *DESC, ELT_ONE /* sort the list on the ELT_2205 colum in descending order and then on ELT_ONE column ascending |
...
SQL
1 - Null values
When reading information from the database, we sometimes have to deal with NULL values.
For example if you want to search for the AVERAGE (or MIN, MAX etc) value of a column, sometimes your *COND(condition) will return no line or you have null values for the specified columns.
...
To do this we have to use indicators.
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ num_bin_2 wIndAverage num_e( 8,2) wAverageValue num_bin_2 wIndMax num_e( 8,2) wMaxValue /* ___ Code _____________________________________________________________________________ chain_sql employee *col( average(age) :wAverageValue :wIndAverage, - max(age) :wMaxValue :wIndMax - *cond( name='milkwater') /* search for the average and max age of employees with name equals to "milkwater" if wIndAverage = -1 /* no value for the average else /* ... end if wIndMax = -1 /* no value for the maximum else /* ... end |
2 - Locked records
One or several lines in a table can be locked. This is caused by a process which modified records in a table without committing the changes. The consequence is that no other process can modify the lines before the first commit or rollback was executed. Even a locked record can not be modified, it can be read by another database user.
...
- VaToolBxSeedRand
- VaToolBxRandom
1 - VaToolBxSeedRand
The VaToolBxSeedRand function is used to reset the pseudo-random number generator, which is used by the VaToolBxRandom function.
2 - VaToolBxRandom
The VaToolBxRandom The VaToolBxRandom function is used to generate random values.
The result is a NUM_BIN_4 number between -2147483648 and 2147483647.
To have a value between 0 and X you can use &ABSOLUTE_VALUE and &MODULO functions (see the example above)
3 - Example
Ancre | ||||
---|---|---|---|---|
|
...
We can use the CALL instruction to call a dynamic program, with static or even dynamic parameters
1 - Dynamic call examples
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ alpha( 10) wProgramObjectFileName alpha( 128) wProgramPublicProcedureName alpha(1000) wParameters num_e( 2,0) myParameterNum01 num_e( 2,0) myParameterNum02 /* ___ Code _____________________________________________________________________________ call myProgram call myProgram.myProcedure myParameterNum01= 22 call myProgram.myProcedure2 myParameterNum01 myParameterNum01= 22 myParameterNum02= 05 call myProgram.myProcedure2 myParameterNum01 myParameterNum02 /* ___ Dynamic program name _____________________________________________________________ wProgramObjectFileName = 'mypgm' call &wProgramObjectFileName wProgramObjectFileName = 'mypgm' call &wProgramObjectFileName.myProcedure /* ___ Dynamic program name and public procedure name ___________________________________ wProgramObjectFileName = 'mypgm' wProgramPublicProcedureName = 'myProcedure' call &wProgramObjectFileName.&wProgramPublicProcedureName wProgramObjectFileName = 'mypgm' wProgramPublicProcedureName = 'myProcedure2' myParameterNum01 = 22 call &wProgramObjectFileName.&wProgramPublicProcedureName myParameterNum /* ___ Dynamic program name, procedure name and parameters ______________________________ wProgramObjectFileName = 'mypgm' wProgramPublicProcedureName = 'myProcedure2' wParameters = '22 05' call &wProgramObjectFileName.&wProgramPublicProcedureName &wParameters |
...
Avertissement | ||
---|---|---|
| ||
It is only available in client part of a cloud generated program (not in a server part or in a server program or in a windows program). |
1 - Set an attribute value
To set a session private attribute value, we simply have to use the VaToolBxCloudSetUserAttribute fonction of the vaToolBx library :
...
The scope of this setting is limited to the current session (logout / logon will destroy all values).
2 - Retrieve an attribute value
To retrieve a session private attribute value, we simply have to use the VaToolBxCloudGetUserAttribute fonction of the vaToolBx library :
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ alpha( 50) wAttributeName alpha(256) wAttributeValue num_bin_4 wAttributeLength /* ___ Code _____________________________________________________________________________ wAttributeName = 'myLabel' /* Label wAttributeValue = *blank wAttributeLength = 256 /* Size of the wAttributeValue variable call_dll 'VaToolBx' 'VaToolBxCloudGetUserAttribute' wAttributeName - wAttributeValue - wAttributeLength if *return_code = *normal /* wAttributeValue contains the value previously saved end |
3 - Delete an attribute value
To delete a session private attribute value, we simply have to use the VaToolBxCloudSetUserAttribute fonction of the vaToolBx library with a blank value :
...
Management rules (MR) can be used if we don't want to repeat the same code on different parts of the code.
The management rule can have parameters and must be seen as a text that will be parsed inside the code.
1 - Parameters
The parameter 1 of the MR will be placed in place of the :01 value etc.
The :01 (:xx) value can be present multiple times inside the MR.
The :01 (:xx) value can be placed anywhere in the code, even to replace an Adelia order or part of it.
Bloc de code | ||
---|---|---|
| ||
/* ___ Management Rule "My_Beautiful_MR" ________________________________________________ /* ___ Declarations _____________________________________________________________________ decl alpha( 50) w:01_val decl ref(cli_usr_:02 client) wCli_usr_:02 decl num_e(9,0) sqlcode_mr /* ___ Code _____________________________________________________________________________ wcli_usr_:02 = :03 if wcli_usr_:02 = *blank wcli_usr_:02 = *user end upd_sql client cli_usr_:02 = :wcli_usr_:02 sqlcode_mr = *sqlcode :06 insert_mr BOL_TRC_:05('*DEBUG';'my beautiful MR, sqlCode : '//sqlcode_mr ;1) :04 = sqlcode_mr |
2 - Usage
To use a MR, we simply have to insert it with the INSERT_MR order
...
To search in the source code we can use L4G editor " File / Multisource search " function with the Regular expression check box selected.
1 - Search examples
Bloc de code |
---|
/* ___ Search for the string XML_OPEN ... *CHECK __________ /* ___ . means any character __________ /* ___ * means any number of times __________ /* ___ .* means any character, any number of times __________ /* ___ \* means the special character * not interpreted as * (multiple) __________ XML_OPEN.*\*CHECK /* ___ Search for the string XML_OPEN ... 'XML' ... 'XML' __________ /* ___ . means any character __________ /* ___ * means any number of times __________ /* ___ .* means any character, any number of times __________ CONV_DATA.*'XML'.*'XML' |
...
BOL debugging
1 - Trace a value
2 - Trace an image value
Added a new bol_trc_imagea management rule to log IMAGE variables.
...
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ image wImage /* ___ Code _____________________________________________________________________________ insert_mr bol_trc_imagea('*DEBUG';'my text ';wImage;1) |
...
BOL database scripts
1 - Set new PAPG values
PAPG example :
Bloc de code |
---|
-- Create program configuration option MYCONFIG delete from wms.hlxprop where XPCPRG = 'MYCONFIG'; insert into wms.hlxprop values('MYCONFIG', 'My configuration', 'MYCONFIG', '007', '011', '0', '0', 0); delete from wms.hlpgpap where GKCPRG = 'MYCONFIG'; insert into wms.hlpgpap values('MYCONFIG',' ','1','0',' '); delete from wms.hlpapdp where GJCPRG = 'MYCONFIG'; insert into wms.hlpapdp values('MYCONFIG',1,'Code',3,' ',' ',' '); insert into wms.hlpapdp values('MYCONFIG',4,'Designation',100,' ',' ',' '); insert into wms.hlpapdp values('MYCONFIG',104,'Active',1,' ',' ',' '); |
...
BOL REST services
1 - Call swagger REST API page
The url address of the swagger REST API page is :
2 - Generate the JWT token
To generate the JWT token, you'll have to access to the following url, but replace XXX with your reflex login and YYY with your reflex password
3 - Apply the JWT token
To apply the JWT token to the rest call, press the Authorize button on top of the REST API page.
...