Error while executing the date macro

If reporting a bug with the Zeus IDE please post the details here. Please do not post questions here.
Post Reply
rbc
Posts: 15
Joined: Thu Feb 17, 2022 3:22 pm

Error while executing the date macro

Post by rbc »

Hi, executing the zScript\date.zm macro inserts the date in dd/mm/yyyy format but also outputs a line like Day: 0 Month: 0 Year 0 and shows the debug output window with the contents as below.

Code: Select all

Unknown Zeus macro function: date
%s Unexpected error running '%s' function.
%s
WARNING: File: "C:\Users\RBC\AppData\Local\Programs\Zeus (x64)\zScript\date.zm" Type: 'Function' Line: 25 Column: 26
Reason: Unknown function 'date'

Macro generated warnings.
Macro script generated '8' Debug, Error and/or Warning message(s).
The actual editing window is populated with the below output, which does contain the date but also the mentioned 0 string.
30/07/2024

Day: 0 Month: 0 Year 0
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Re: Error while executing the date macro

Post by jussij »

The macros with the .zm file extension are the original Zeus macros that ran using a 'home-grown' scripting engine. The bug you are seeing is some aging of that engine which was long ago relaced by more powerful engines running Python and Lua. This particular error is a date function that appears to no longer exist.

In any case the date.zm macro can be fixed by making the following code changes:

Code: Select all

int DateMacro()
{
  // this macro will only work for document windows so check first
  if (is_document() == 0)
  {
    message("This macro only works for document files!");
    beep();
    return;
  }

  StampDateTime();
  MoveLineEnd();
  Enter();
  Enter();
  string current_date = macro_tag("$DT<d MMMM yyyy>");
  printf("%s\n", current_date);
  Enter();
  string day = macro_tag("$DT<dd>");
  string month = macro_tag("$DT<MM>");
  string year = macro_tag("$DT<yyyy>");
  printf("%s/%s/%s", day, month, year);
  return 1;
}
That changed macro code will produce this output:
30/07/2024

30 July 2024

30/07/2024
Jussi
rbc
Posts: 15
Joined: Thu Feb 17, 2022 3:22 pm

Re: Error while executing the date macro

Post by rbc »

That makes sense, thanks Jussi. To be honest, it's something I stumbled upon by accident so I thought I'd report it but its not like its a big deal. I was on the Execute Script dialog where I happened to enter just date instead of datetime and got surprised by the error.

As an aside, are both the Python and Lua macro engines considered current and fully supported?
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Re: Error while executing the date macro

Post by jussij »

As an aside, are both the Python and Lua macro engines considered current and fully supported?
Yes they are. Both the Lua and Python engines are updated periodically with the latest Lua and Python releases.

The Zeus Python engine is running the Python 3.11.4 version, and the Zeus Lua engine is running the Lua 5.4.0 version.

Python is currently sitting at version 3.12.4 and Lua is sitting at 5.4.7 so both engines are only few changes behind.

Jussi
Post Reply