I'm trying to make it so that properties are easily adjustable using a .ini file.
The problem currently is that currently these properties are defined using the "&global-define". With this the properties are not easily adjustable.
I want to put all of these variables inside of a settings file, and import that settings file inside of the procedure. I was thinking about using a settings.ini file for this.
I hope I can further clarify what I'm trying to achieve down below.
settings.ini
port = 19995
procedure.p
import settings.ini .
define variable iPort as integer no-undo .
iPort = port .
Let me know if more explanation is needed.
Thanks in advance
I looked for a solution on the internet but was unable to find one.
A solution I tried was reading the file and based on the propertyName I would assign a variable, however this seems very inefficient when dealing with a high amount of variables. Example shown below:
input from value("settings.ini") .
repeat:
import unformatted vLine.
iIndex = index(vLine, "=") .
cPropertyName = trim (substring (vLine, 1, iIndex - 1)) .
cPropertyValue = trim (substring (vLine, iIndex + 1)) .
case cPropertyName:
when "port" then
if cPropertyValue <> "" then iPort = cPropertyValue .
else iPort = "" .
end case.
end.
input CLOSE.
Another solution I found was: https://community.progress.com/s/article/is-it-possible-to-set-custom-variables-in-an-ini-file-to-use-with-abl-code
But as stated in the comments this solution only works for windows.
I now have a new solution which makes use of a temp-table: procedure.p
define temp-table ttSettings no-undo
field port as integer .
temp-table ttSettings:read-json ("file", "settings.json").
find first ttSettings .
message ttSettings.port view-as alert-box.
settings.json
{
"port": 19995
}