Tormy wrote:
It's arrived the moment to work with. But to write each time the function is really not practical.
I'm wondering if is there any possibility to write it into a file and import it time by time.
In theory, yes. In practice, no.
Pascal has a feature called Include directive to import code from external files within the search path:
Code:
{$INCLUDE 'base64encode.pal'}
Only problem is since PAL is an embedded ObjectPascal inside another ObjectPascal application, you can't modify the search path and can't even print it.
I'm not even sure if it's possible to have it search in the filesystem or if it's limited to resources embedded in the SAMBC.exe binary.
The default case for include would be to search in the same directory as the file you compile or in the full path given to the include directive, but neither seems to work in PAL.
Feel free to investigate further, the engine used to build PAL is called DwScript.
Tormy wrote:
base64 is really practical when you need to send several arguments using GET and sometimes also POST, if ever strange characers are used etc ...
Base64 is great for exchanging binary data.
If you have any kind of structured, text-based/numeric data, base64 is NOT the way to go.
Tormy wrote:
when sent in base64 is much "lighter" and it can be decoded from the other side quite easily
When sent in JSON it's much easier to read and diagnose problems and it can be decoded by all kinds of software and if there's no native support it's easy to decode using basic string manipulation.
Tormy wrote:
I'm find also strange that in 20 years no one yet implemented a readymade function in PAL
Have you ever had a look at the PAL forums and what people try to achieve with it or want from PAL?
There are like 30 people in the history of this forum that went beyond Playlist automation with PAL. I doubt there are more than 2-3 people that would ever find a use for base64 in PAL, even if you told them about it.
Feel free to ask the Spacial support for it, though. After all, they also exposed the Delphi THttp API to PAL after being asked about TLS support and more complex API support.