Kramer_Gunter
(Softtouch Software Design)
October 21, 2016, 8:00am
1
I cannot get it to work, the help file is not really a help.
I want to user anyhow the date functions (dateutils) from a script to calculate some dates, but I am not able to do so.
for example, I want to use the EncodeDate and YearsBetween in a script, how to do that???
Kramer_Gunter
(Softtouch Software Design)
October 21, 2016, 8:26am
2
Figured it out, adding ap_dateutils to the pascal codse and DateUtils to the script.
Seems to be case sensitive. Adding dateutil top the script result in a not found exception.
wlandgraf
(Wagner Landgraf)
October 21, 2016, 12:07pm
3
It's not case sensitive. Did you add "dateutils" or "dateutil" (which would not work)?
Kramer_Gunter
(Softtouch Software Design)
October 27, 2016, 5:33am
4
Hm thanks. It must have been misspelled. Now it works.
But I run into another issue. I added ap_strutils to the uses clause in the delphi program, and strutils to the uses clause of the script, and it cant find the definition of rfReplaceAll for stringreplace.
Kramer_Gunter
(Softtouch Software Design)
October 27, 2016, 5:58am
5
Unfortunately, I cannot edit or delete a message once posted :(
I added ap_sysutils, ap_strutils etc., and it still cannot resilve rfreplaceall, but thats ok, I definied it.
What is wrong with this?
Script:
uses
SysUtils;
const
rfReplaceAll = 0;
procedure GetData(code);
var
s;
begin
s:=stringreplace(code,'{','',[rfReplaceAll]);
end;
Delphi:
scripter:=TatPascalScripter.Create(nil);
scripter.SourceCode.LoadFromFile('f:\test.txt');
scripter.ExecuteSubroutine('GetData',s);
I get an exception:
wlandgraf
(Wagner Landgraf)
October 27, 2016, 1:24pm
6
[rfReplaceAll] for scripter is an array constructor.
To create a set, you use this:
SetOf([rfReplaceAll])
so:
s:=stringreplace(code,'{','',SetOf([rfReplaceAll]));
Kramer_Gunter
(Softtouch Software Design)
October 28, 2016, 3:49pm
7
Thank you very much, that works. Is there any help file listing such changes?
wlandgraf
(Wagner Landgraf)
October 28, 2016, 7:19pm
8
That function is listed at the end of this topic: