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 :
In details we have
- 4GL instructions list (or by topic )
- Grahpical objects
- Predefined functions (or by topic )
- Reserved words
- VaToolBx functions (or by topic )
...
Shortcuts
CTRL+D | Sends to the nearer declaration paragraph . Pressing it again brings you back to the line where you was before. |
CTRL+SHIFT+D | Sends to the program declaration paragraph . Pressing CTRL+SHIFT+D again brings you back to the line you were before. |
CTRL+SHIFT+I | Indent the selected part of your source code ( don't indent all the source code as it would break all manual source code alignments) |
CTRL+ALT+S | Change selected lines to the server part (red line on the left) |
CTRL+ALT+L | Change selected lines to the client part (remove the red line on the left, opposite of CTRL+ALT+S ) |
CTRL+SHIFT+F | Open the Adelia Multisearch menu |
CTRL+SHIFT+V | Runs the Verification action, to check if the Adelia code is valid |
CTRL+SHIFT+G | creates in compile job in the Adelia job manager |
CTRL+F3 | Search for the selected text in the code. works as well for selected procedures. |
F3 | Jump to the next code line which contains the search string. |
SHIFT+F3 | Jump to the previous code line which contains the search string. |
F8 | Jump to the next code line with an error detected by AdeliaStudio verification. |
SHIFT+F8 | Jump to the previous code line with an error detected by AdeliaStudio verification. |
CTRL+F7 F7 | create and remove line bookmarks |
ALT+DOWN | used when the cursor is on a variable or other Adelia object in the editor. Jump to the declaration of this object. |
Avertissement |
---|
Don't indent all the source (CTRL+SHIFT+S) as it would break all manual source alignments. |
...
Declarations
1 - Reference declarations
When declaring variables it is better to declare in reference to another variable or property (of an LDM). If the LDM is not used in the program, you can also specify that the property belongs to a LDM in the REF order.
When declaring lists it is better to declare in reference to an LDM (1 or more LDM if needed).
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 .
The length can also be indicated in :
- kilobytes (* 1024) by adding the suffix "K" to the value (up to 8189K), or
- megabytes (* 1048576) by adding the suffix "M" to the value (up to 7M)
Remarque | ||
---|---|---|
| ||
If possible, ALPHA variables must be declared in reference to another variable. |
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)
The total length value range from 1 to 63 .
The length value is the total number of digits.
The decimal value is included in the number of digits .
So, as the decimal value is included in the number of digits, the decimal value must be less than or equal to the length.
Remarque | ||
---|---|---|
| ||
If possible, NUM_E variables must be declared in reference to another variable. |
Bloc de code | ||
---|---|---|
| ||
/* ___ Variables declarations ___________________________________________________________
NUM_E( 8,0) MyNum1 /* 8 digits, 8 for the integer part, 0 for the decimal part
NUM_E( 15,3) MyNum2 /* 15 digits, 12 for the integer part, 3 for the decimal part
NUM_E( 5,5) MyNum3 /* 5 digits, 0 for the integer part, 5 for the decimal part |
...
Constants
Constants must be used in order to replace an hard coded value in a code.
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 .
Astuce | ||
---|---|---|
| ||
The Modulo predefined function can now be used instead of the remainder instruction ! |
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 :
- DECL PGM . In this paragraph, we declare the global variables (or parameters, lists, cursors etc) of the program,
- INIT PGM . This is the entry point of the program,
- WIN DECLARATION . In this paragraph, we declare the variables (lists, cursors etc) only accessible from within the window paragraphs (Initialisation, Verification, Validation, Events),
- WIN EVENTS . In those paragraph we will code what happens when a event is triggered for an object ,
- INITIALIZATION . In this paragraph, we will add code to load data before displaying the window ,
- VERIFICATION . In this paragraph, we will add code to verify the data entered in the window by a user,
- VALIDATION . In this paragraph, we will add code to store the data in the database after verification .
- PROCEDURES . Procedures can be added to do repetitive tasks or to cut the other paragraphs in more readable parts.
A typical simple framework code would be the following :
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
...
String functions
1 - Concatenate alphanumerical variables
To concatenate two (or more variables) you can use the // or /// operator.
- // operator will exactly concatenate the two variables (lenght of left operator exactly concatenated to lenght of right operator)
- /// operator will eliminate the blanks on the right part of the left 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 calculate the length of a string, you simply have to use the &LONGUEUR_CHAINE predefined function :
Bloc de code |
---|
/* ___ Déclarations _____________________________________________________________________
num_bin_2 stringLength
alpha(100) myString
/* ___ Code _____________________________________________________________________________
myString = '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 :
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________
alpha( 50) elementDay
list lst_days elementDay
alpha(1000) myDays
/* ___ Code _____________________________________________________________________________
myDays = '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
In order to replace a substring in a string, you simply have to use the SCAN_REPLACE instruction :
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________
alpha(1000) myDays
alpha(1000) myDaysModified
alpha( 56) mySearchString
alpha( 78) myReplacementString
/* ___ Code _____________________________________________________________________________
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 _____________________________________________________________________
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 intervals between Dates, Times and Timestamps, we can use the following functions
- &Date_Interval
- &Time_Interval
- &Timestamp_Interval
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________
date myDate1
date myDate2
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 days between myDate1 and myDate2 (can be a negative number if myDate1 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)
|
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 _____________________________________________________________________
date myDate
num_e(4,0) myYear
num_e(2,0) myMonth
num_e(2,0) myDay
/* ___ Code _____________________________________________________________________________
myYear = &date_to_year(myDate) /* extract the year from 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' '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.
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)
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).
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 /* 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).
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 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.
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')
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 _____________________________________________________________________________
/* ___ 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
Ancre | ||||
---|---|---|---|---|
|
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 _____________________________________________________________________________
/* ___ 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
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
|
...
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" ________________________________________________
/* ___ 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
Bloc de code | ||
---|---|---|
| ||
/* ___ Code _____________________________________________________________________________
insert_mr my_beautiful_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 | ||
---|---|---|
| ||
/* ___ Declarations _____________________________________________________________________
graphic_object(colonne) colObjVar
/* ___ Code _____________________________________________________________________________
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.
The associated fields starts with ZZ, followed by the same 4 characters.
The guide word is the same as the property name.
The associated guide word, starts with a Z followed by the name of the property without the entity prefix.
...
Code tips
Bloc de code |
---|
/* ___ Declarations _____________________________________________________________________
num_e(3,0) wValue
/* ___ Code _____________________________________________________________________________
if wValue = 1 or wValue = 5 or wValue = 8 then /* is equivalent to
if wValue = 1;5;8 then
if wValue <> 1 and wValue <> 5 and wValue <> 8 then /* is equivalent to
if wValue <> 1;5;8 then |
...
Search tips (using regular expression)
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.
This new management rule works like the BOL_TRC management rule, except it has a new parameter that will be concatenated to the text.
Avertissement |
---|
The image variable must contains text. It can be for example an image variable containing XML. |
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.
Then enter "JWT" , a space character AND the token generated for your user/pass informations.
Then press Authorize button.xxx