When you reference a declaration in the library from other logic such as a service or handler, you can include the library name as a prefix. For example, MyLibrary.myLibraryVariable is appropriate if the library name is MyLibrary and the library includes the myLibraryVariable variable. Alternatively, you can include the library name in a use statement in the other logic and avoid the need to qualify every reference. In that case, myLibraryVariable is sufficient to reference that variable.
To create a Library part:
PaymentLib
libraries
package libraries;
library PaymentLib type BasicLibrary {}
end
categories STRING[] = [
"Rent", // 1
"Food", // 2
"Entertainment", // 3
"Automotive", // 4
"Utilities", // 5
"Clothes", // 6
"Other" // 7
];
The value is an array, and as is true of all arrays in EGL, the index of the first element is 1, not 0.
function getCategoryDesc(cat INT in) returns(STRING)
if(cat) // the integer is not 0
return(categories[cat]);
else
return("");
end
end
The function receives the integer format of an expense category and returns the related array element. If the input value is 0, the function returns an empty string.
function getCategoryNum(desc STRING in) returns(INT)
for(i INT from 1 to categories.getSize())
if(categories[i] == desc)
return(i);
end
end
return(0); // no match
end
This function receives the string format of an expense category and returns the integer format, if possible. If no match is found for the received string, the function returns 0.