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, In order to replace a substring in a string, you simply have to use the SCANSPLIT_REPLACE instruction STRING 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' mySearchStringsplit_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 _____________________________________________________________________________ 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
myDays = '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 _____________________________________________________________________ dateALPHA( 1) wCR ALPHA( 1) wLF myDate dateALPHA( 2) wCRLF ALPHA(100) wText myNewDate time_t MyTime time_t MyNewTime timestamp MyTimestamp timestamp MyNewTimestamp /* ___ Code /* ___ Code _________________________________________________________________________________ myNewDatewCR = &calculateCHAR_dateCONVERSION(myDate;1;'Y0D') /* add 1 Year to myDate myNewDate wLF = &calculateCHAR_dateCONVERSION(myDate;-6;'M0A') 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 /* substract 6 Months to myDate myNewDate = &calculate_date(myDate;40;'D') /* add 40 Days to myDate myNewTime = &calculate_time(myTime;1;'H') myDate date myNewDate time_t /* add 1 Hours to myTime myNewTime = &calculate_time(myTime;-6;'M')MyTime time_t MyNewTime timestamp MyTimestamp timestamp MyNewTimestamp /* substract___ 6 Minutes to myTime myNewTimeCode _____________________________________________________________________________ myNewDate = &calculate_timedate(myTimemyDate;401;'SY') /* add 401 SecondsYear to myTimemyDate myNewTimestampmyNewDate = &calculate_tmsdate(myTimestampmyDate;1-6;'Y M') /* addsubstract 16 YearMonths to myTimestampmyDate myNewTimestampmyNewDate = &calculate_tmsdate(myTimestampmyDate;-640;'M D') /* substract 6 Months myTimestamp myNewTimestamp /* add 40 Days to myDate myNewTime = &calculate_tmstime(myTimestampmyTime;401;'D H') /* add 401 DaysHours to myTimestampmyTime myNewTimestampmyNewTime = &calculate_tmstime(myTimestampmyTime;1-6;'H M') /* addsubstract 16 HoursMinutes to myTimestampmyTime myNewTimestampmyNewTime = &calculate_tmstime(myTimestampmyTime;-640;'MIS') /* substractadd 640 MinutesSeconds to myTimestampmyTime myNewTimestamp = &calculate_tms(myTimestamp;401;'SY ') /* add 401 SecondsYear to myTimestamp myNewTimestamp = &calculate_tms(myTimestamp;-306;'MSM ') /* substract 30 Seconds to myTimestamp |
2 - Calculating intervals between dates, time and timestamp values
In order to calculate intervals between Dates, Times and Timestamps, we can use the following functions
- &Date_Interval
- &Time_Interval
- &Timestamp_Interval
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ date6 Months myTimestamp myNewTimestamp = &calculate_tms(myTimestamp;40;'D ') /* myDate1 date add 40 Days to myTimestamp myNewTimestamp = &calculate_tms(myTimestamp;1;'H ') myDate2 time_t /* add 1 Hours myTime1 time_tto myTimestamp myNewTimestamp = &calculate_tms(myTimestamp;-6;'MI') myTime2 timestamp /* myTimestamp1 timestampsubstract 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 intervals between Dates, Times and Timestamps, we can use the following functions
- &Date_Interval
- &Time_Interval
- &Timestamp_Interval
Bloc de code |
---|
/* ___ Declarations myTimestamp2 num_e(9,0) myInterval1 num_e(9,0) myInterval2 num_e(15,0) myInterval3 /* ___ Code _____________________________________________________________________________ myInterval1 = &date_interval(myDate1;myDate2) myDate1 date /* number of days between myDate1 and myDate2 (can be a negative number if myDate1 if greater than myDate2) myInterval2 = &time_interval(myTime1;myTime2myDate2 time_t myTime1 time_t myTime2 timestamp myTimestamp1 timestamp myTimestamp2 num_e(9,0) myInterval1 num_e(9,0) myInterval2 num_e(15,0) myInterval3 /* ___ Code _____________________________________________________________________________ myInterval1 = &date_interval(myDate1;myDate2) /* number of secondsdays between myTime1myDate1 and myTime2myDate2 (can be a negative number if myTime1myDate1 if greater than myDate2) myInterval2 = &time_interval(myTime1;myTime2) /* number of seconds between myTime1 and myTime2 (can be a negative number if myTime1 if greater 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) |
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 :
3 - Extract informations from a Date variable
In order to extract informations from a Date variable, we can use the following functions
- &Date_To_Year
- &Date_To_Month
- &Date_To_Day
- &Date_To_Num
Bloc de code |
---|
/* ___ Déclarations |
Bloc de code |
/* ___ Declarations _____________________________________________________________________ alpha( 100) fileAlias alpha( 10) fileMode alpha(5000) myAlpha image myImage num_bin_4 nb4ReturnCodedate myDate num_e(4,0) myYear num_e(2,0) myMonth num_e(2,0) myDay /* ___ Code _____________________________________________________________________________ myAlphamyYear = 'my text= &date_to_year(myDate) 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 imageextract the year from the date myDate (year will be in format CCYY (century + year) myMonth = &date_to_month(myDate) 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
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 : 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 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.
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 ______ |
Bloc de code |
/* ___ Lists usage _______________________________________________________________ ELT_ONE = 1 ELT_TWO = 2 ELT_2205 = 2205 INSERT_ELT LST_EXAMPLE INSERT_ELT LST_EXAMPLE *BEGIN /* to insert an element in the list at the start of the list INSERT_ELT LST_EXAMPLE *END /* to insert an element in the list at the end of the list (as it is the default value, it can be omitted) INSERT_ELT LST_EXAMPLE *BEFORE /* to insert an element in the list before the current element INSERT_ELT LST_EXAMPLE *AFTER /* to insert an element in the list after the current element INSERT_ELT LST_EXAMPLE *SORT(ELT_2205 *DESC, ELT_TWO *ASC) /* to insert an element in the list sorted by ELT_2205 descending, then ELT_TWO ascending (*ASC is default so it can be omitted) INSERT_ELT LST_EXAMPLE *CHANGE /* to insert an element AND make it a changed element (could be retrieved by a READ_LST LST_EXAMPLE *CHANGE ... END_READ_LST |
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)
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' '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 ____________ |
Bloc de code |
/* ___ Lists usage _______________________________________________________________ READ_LST LIST LST_EXAMPLE /* ELT_ONE is filled with the value of the first line on the first iteration of the list, same for 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 IF ... DELETE_ELT LST_EXAMPLE *REF_LDM(HL_ART_ALCOOL) /* wedefining cana deletelist thewith currentall elementthe properties of END IF ... ELT_ONE = ELT_ONE + 1 CHANGE_ELT LST_EXAMPLE the HL_ART_ALCOOL ldm LIST LST_ART_ALC_3 *REF_LDM(HL_ART_ALCOOL) *REF_LDM(HL_ART_LANGUE) /* defining a welist canwith changeall the valuesproperties 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).
We can also use READ_L_ELT (read last element) and READ_PR_ELT (read previous element).
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.
Bloc de code |
---|
/* |
Bloc de code |
/* ___ Lists usage _______________________________________________________________ ELT_ONE = 1 ELT_TWO = 2 ELT_ READ_F2205 = 2205 INSERT_ELT LST_EXAMPLE INSERT_ELT LST_EXAMPLE *BEGIN /* weto tryinsert toan readelement in the first elementlist at the start of the list (if it exists) DO_WHILE &CODE_LST( INSERT_ELT LST_EXAMPLE) = *NORMALEND /* did to insert an element in the list lastat the operationend onof the list end successfully ? ... READ_NX_(as it is the default value, it can be omitted) INSERT_ELT LST_EXAMPLE *BEFORE /* try to readinsert thean next element ofin the list REDO READ_L_ before the current element INSERT_ELT LST_EXAMPLE *AFTER /* weto tryinsert to read the last an element ofin the list after (ifthe itcurrent exists)element DOINSERT_WHILEELT &CODE_LST(LST_EXAMPLE) = *NORMALLST_EXAMPLE *SORT(ELT_2205 *DESC, ELT_TWO *ASC) /* didto theinsert lastan operationelement onin the list end successfully ? ... READ_PRsorted by ELT_2205 descending, then ELT_TWO ascending (*ASC is default so it can be omitted) INSERT_ELT LST_EXAMPLE *CHANGE /* try to readinsert thean nextelement elementAND ofmake 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).
it a changed element (could be retrieved by a READ_LST LST_EXAMPLE *CHANGE ... END_READ_LST |
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)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).
Bloc de code |
---|
/* ___ Lists declarationsusage _______________________________________________________________ LIST READ_LST LST_EXAMPLE /* ELT_ONE ELT_TWO ELT_2205 /* defining a list with single elements defined previously, here 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 variables LIST_INDEX MY_INDEX ... IF ... DELETE_ELT LST_EXAMPLE ELT_2205 /* we can delete /*the wecurrent defineelement the MY_INDEX indexEND that will index the LST_EXAMPLE list on the ELT_2205 column /* ___ Lists usage _______________________________________________________________ ELT_2205 = 67 /* we set the value we want to reach in the list READ_ELT MY_INDEX /* we try to read the first element of the list with the value 67 in the column ELT_2205 IF &CODE_LST(MY_INDEX) = *NORMAL /* did the find the element with the searched value ? ... /* if yes, then we are on the element, we can use it, modify it or delete it. END ELT_2205 = 67 READ_F_ELT MY_INDEX /* reads the first element that is greater or equal to the column value of the index DO_WHILE &CODE_LST(MY_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).
We can also use READ_L_ELT (read last element) and READ_PR_ELT (read previous element).
Bloc de code |
---|
/* ___ Lists usage _______________________________________________________________ READ_F_ELT LST_EXAMPLE INDEX) = *NORMAL ... READ_NX_ELT MY_INDEX REDO DELETE_INDEX MY_INDEX /* deletewe thetry indexto ifread it'sthe notfirst needed anymore, to free the memory used by the index |
An index is first created when the first read is done on on it (with READ_ELT or READ_F_ELT).
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 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 /* copytry theto content ofread the listnext LST_ONEelement inof 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.
And sometime you have to know that there is no value.
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.
With the reserved world *LOCKED, it is possible in Adelia to check if a record is locked. It needs to be used after a database modification statement (UPD_SQL or DELETE).
- *LOCKED = '1' : record is locked
- *LOCKED = '0' : record is not locked (we can use the constant _RECORD_LOCKED instead of the value '1')
...
title | Attention |
---|
...
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).
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_INDEX MY_INDEX LST_EXAMPLE ELT_2205 /* we define the MY_INDEX index that will index the LST_EXAMPLE list on the ELT_2205 column
/* ___ Lists usage _______________________________________________________________
ELT_2205 = 67 /* we set the value we want to reach in the list
READ_ELT MY_INDEX /* we try to read the first element of the list with the value 67 in the column ELT_2205
IF &CODE_LST(MY_INDEX) = *NORMAL /* did the find the element with the searched value ?
... /* if yes, then we are on the element, we can use it, modify it or delete it.
END
ELT_2205 = 67
READ_F_ELT MY_INDEX /* reads the first element that is greater or equal to the column value of the index
DO_WHILE &CODE_LST(MY_INDEX) = *NORMAL
...
READ_NX_ELT MY_INDEX
REDO
DELETE_INDEX MY_INDEX /* delete the index if it's not needed anymore, to free the memory used by the index |
An index is first created when the first read is done on on it (with READ_ELT or READ_F_ELT).
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 Codeusage _______________________________________________________________ CLEAR______________ /* ___ Force Oracle to answer after a certain amount of time, even if the record is locked ______________________________ /* ___ Here we will have an answer after 5 seconds maximum. _____________________________________________________________ /* ___ The 'P' parameter means all the queries submitted during the session will have this timeout delay ________________ /* ___ A 'T' parameter would mean that only the next query submitted during the session would have this timeout delay ___ call_dll 'VATOOLBX.DLL' 'VaToolBxSetTimeOut' 5 'P' returnCodeBool /* ___ Try to do an update to a database record ___ upd_sql employee age = age + 1 - *cond( name='milkwater') if *locked = _RECORD_LOCKED /* the record(s) is(are) locked else /* the record(s) is(are) not locked and has been updated end |
Random values
In order to generate random values, we can use 2 functions of the VaToolBx package in Adelia.
- 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 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
...
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.
And sometime you have to know that there is no value.
To do this we have to use indicators.
Bloc de code |
---|
/* ___ Declarations |
...
Example to retrieve a value between 1 and 10 :
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________ num_e(6,0) wTime num_bin_4 wSeedValue num_bin_4 wRandomValue /* ___ Code ____________________ num_bin_2 wIndAverage num_e( 8,2) wAverageValue num_bin_2 wIndMax num_e( 8,2) wMaxValue /* ___ Code ________________________________________________ /* ___ Generate a seed value ____________________________________________________________ time wTime wSeedValue = wTime call_dll 'vatoolbx.dll' 'VaToolBxSeedRand' wSeedValue /* ___ Generate a random value __________________________________________________________ call_dll 'vatoolbx.dll' 'VaToolBxRandom' wRandomValue /* ___ Calculate a value between 1 and 10 _______________________________________________ wRandomValue = &absolute_value(wRandomValue) wRandomValue = &modulo(wRandomValue;10) wRandomValue = wRandomValue + 1 |
Dynamic program call
We can use the CALL instruction to call a dynamic program, with static or even dynamic parameters
1 - Dynamic call examples
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.
With the reserved world *LOCKED, it is possible in Adelia to check if a record is locked. It needs to be used after a database modification statement (UPD_SQL or DELETE).
- *LOCKED = '1' : record is locked
- *LOCKED = '0' : record is not locked (we can use the constant _RECORD_LOCKED instead of the value '1')
Remarque | ||
---|---|---|
| ||
By default Oracle waits an infinite amount of time after an update (or delete) operation if the record is locked. |
Bloc de code |
---|
/* ___ Code _____ |
Bloc de code |
/* ___ Declarations _____________________________________________________________________ alpha( 10) wProgramObjectFileName alpha( 128) wProgramPublicProcedureName alpha(1000) wParameters num_e( 2,0) myParameterNum01 num_e( 2,0) myParameterNum02 /* ___ Code ___ /* ___ Force Oracle to answer after a certain amount of time, even if the record is locked ______________________________ /* ___ Here we will have an answer after 5 seconds maximum. ____________________________________________ call myProgram call myProgram.myProcedure myParameterNum01= 22 call myProgram.myProcedure2 myParameterNum01 myParameterNum01= 22 myParameterNum02= 05 call myProgram.myProcedure2 myParameterNum01 myParameterNum02 /* ___ Dynamic program name ________________________ /* ___ The 'P' parameter means all the queries submitted during the session will have this timeout delay __________________ /* ___________________ wProgramObjectFileName = 'mypgm' call &wProgramObjectFileName wProgramObjectFileName = 'mypgm' call &wProgramObjectFileName.myProcedure A 'T' parameter would mean that only the next query submitted during the session would have this timeout delay ___ call_dll 'VATOOLBX.DLL' 'VaToolBxSetTimeOut' 5 'P' returnCodeBool /* ___ Try to Dynamicdo programan nameupdate andto publica proceduredatabase namerecord ___________________________________ wProgramObjectFileName = 'mypgm' wProgramPublicProcedureName = 'myProcedure' call &wProgramObjectFileName.&wProgramPublicProcedureName wProgramObjectFileName = 'mypgm' wProgramPublicProcedureName = 'myProcedure2' myParameterNum01 = 22 call &wProgramObjectFileName.&wProgramPublicProcedureName myParameterNum /* ___ Dynamic program name, procedure name and parameters _____ upd_sql employee age = age + 1 - *cond( name='milkwater') if *locked = _RECORD_LOCKED /* the record(s) is(are) locked else /* the record(s) is(are) not locked and has been updated end |
...
Random values
In order to generate random values, we can use 2 functions of the VaToolBx package in Adelia.
- 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 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 | ||||
---|---|---|---|---|
|
Example to retrieve a value between 1 and 10 :
Bloc de code |
---|
/* ___ Declarations _________________________ wProgramObjectFileName = 'mypgm' wProgramPublicProcedureName = 'myProcedure2' wParameters = '22 05' call &wProgramObjectFileName.&wProgramPublicProcedureName &wParameters |
Users's attribute
User session can be used to store and retrieve values.
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 :
Bloc de code |
---|
/* ___ Declarations _____________________________________________ num_e(6,0) wTime num_bin_4 wSeedValue num_bin_4 wRandomValue /* ___ Code _____________________________________________________________________________ alpha( 50) wAttributeName alpha(256) wAttributeValue /* ___ Code __Generate a seed value ___________________________________________________________________________ wAttributeName = 'myLabel' /* Label wAttributeValue = 'xxxyyyzzz' /* Value to be stored under the user session (must be alpha value) time wTime wSeedValue = wTime call_dll 'VaToolBxvatoolbx.dll' 'VaToolBxCloudSetUserAttributeVaToolBxSeedRand' wAttributeNamewSeedValue - /* ___ Generate a random wAttributeValue |
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 value __________________________________________________________ call_dll 'vatoolbx.dll' 'VaToolBxRandom' wRandomValue /* ___ Calculate a value between 1 and 10 ___________________________________ alpha( 50) wAttributeName ____________ wRandomValue = &absolute_value(wRandomValue) wRandomValue = &modulo(wRandomValue;10) wRandomValue = wRandomValue + 1 |
...
Dynamic program call
We can use the CALL instruction to call a dynamic program, with static or even dynamic parameters
1 - Dynamic call examples
Bloc de code |
---|
alpha(256) wAttributeValue num_bin_4 wAttributeLength /* ___ CodeDeclarations _____________________________________________________________________________ wAttributeName alpha( 10) = 'myLabel' /* Label wAttributeValue = *blank wAttributeLength = 256 /* Size of the wAttributeValue variable call_dll 'VaToolBx' 'VaToolBxCloudGetUserAttribute' wAttributeName - 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 wAttributeValue = -'mypgm' wProgramPublicProcedureName = 'myProcedure2' myParameterNum01 = 22 call &wProgramObjectFileName.&wProgramPublicProcedureName myParameterNum /* ___ Dynamic program name, procedure name and parameters ______________________________ wProgramObjectFileName = 'mypgm' wProgramPublicProcedureName = 'myProcedure2' wParameters 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 :
= '22 05'
call &wProgramObjectFileName.&wProgramPublicProcedureName &wParameters
|
...
Users's attribute
User session can be used to store and retrieve values.
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 :
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________
alpha( 50) wAttributeName
alpha(256) wAttributeValue
/* ___ Code _____________________________________________________________________________
wAttributeName = 'myLabel' /* Label
wAttributeValue = 'xxxyyyzzz' /* Value to be stored under the user session (must be alpha value)
call_dll 'VaToolBx' 'VaToolBxCloudSetUserAttribute' wAttributeName -
wAttributeValue |
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 :
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________
alpha( 50) wAttributeName
alpha(256) wAttributeValue
/* ___ Code _____________________________________________________________________________
wAttributeName = 'myLabel' /* Label
wAttributeValue = *blank /* *blank to delete the label from the user's session
call_dll 'VaToolBx' 'VaToolBxCloudSetUserAttribute' wAttributeName -
wAttributeValue |
...
Management Rules
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" ________________________________________________
| ||
Bloc de code | ||
/* ___ Declarations _____________________________________________________________________ decl alpha( 50) w:01_val decl ref(cli_usr_:02 client) wCli_usr___ alpha( 50) wAttributeName alpha(256) wAttributeValue:02 decl num_e(9,0) sqlcode_mr /* ___ Code _____________________________________________________________________________ wAttributeNamewcli_usr_:02 = 'myLabel':03 /* Label wAttributeValue = *blank /* *blank to delete the label from the user's session call_dll 'VaToolBx' 'VaToolBxCloudSetUserAttribute' wAttributeName - wAttributeValue |
Management Rules
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
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 orderThe 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" _____________________________________/* ___ Code ___________ /* ___ Declarations _______________________________________________________________ insert_mr my_____ decl alpha( 50) w:01_val decl ref(cli_usr_:02 client) wCli_usr_:02 decl num_e(9,0) sqlcode_mrbeautiful_mr(test;cre;'milkwater';mrReturnCode;C; ) insert_mr my_beautiful_mr(test;maj;*blank;mrReturnCode;S;*) |
...
Graphical objects
1 - get an object from his object name
In order to get the handle of an object from the name of the object it's possible to use the predefined function &GET_OBJECT :
Bloc de code | ||
---|---|---|
| ||
/* ___ CodeDeclarations _____________________________________________________________________________ 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
Bloc de code | ||
---|---|---|
| ||
graphic_object(colonne) colObjVar /* ___ Code _____________________________________________________________________________ insert_mr my_beautiful_mr(test;cre;'milkwater';mrReturnCode;C; ) insert_mr my_beautiful_mr(test;maj;*blank;mrReturnCode;S;*)colObjVar = &get_object('col_01') colObjVar:visibility = *true |
...
Resources
Ressources are typically used to import "external" objects in the adelia environment.
The advantage to import an object in the adelia environment is that we don't need any more the external object to use it.
It will be saved also with the backup of the environment.
1 - Creation of a resource
A resource is defined with
- name : public name of the object,
- Type : must be object,
- Program Type : where the program will be used (most of the time in windows and cloud clients)
- File name : name of the file if it is exported
- Destination : folder for the export of the resource (not used most of the time)
2 - Usage of a resource
In the BOL environment, the resources can be used for images.
When using an image (or icon) in a window, we should use a resource instead of importing the image from file system :
3 - Benefits of resources
When a resource is used (eventually in multiple programs), if we want to modify an object (image, icon, etc) , we just need to modify the resource, then analyze the resource in order to have the usage of the resource and generate the programs found.
...
For example, if we modify the "reduced icon" image, we just have to modify the resource used and generate the programs. We don't have to go to all the windows to change the Reduced Icon image again.
...
Logical Data Model
1 - How to retrieve the name of the Adelia Logical Entity from the name of the Table
In order to retrieve the name of the Adelia Logical Entity from the real name of the table , we can use the Maintenance manager accessible from the Session manager .
...
Then, if we select File/Table as object attribute , Logical Entity as Object type , BOLLOGP* (for example) as File name and if we press Find button , the system will show us with all the Adelia Logical files that have this part of name in the physical name :
2 - Property naming convention
The short name starts with the entity prefix (in this case RH) followed by 4 characters.
...
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.
...