question

Mischa Spelt avatar image
1 Like"
Mischa Spelt asked Jordan Johnson edited

Global Macros not evaluated in Process Flow queries?

We often use Global Macros to define useful constants, for example gettablenum( SETTINGS_TABLE, SETTING_RUNTIME_ROW, SETTING_VALUE_COL) is more readable and maintainable than gettablenum("Settings", 3, 2).

However, it seems that the query strings in for example Process Flow's Pull from list or Acquire Resource activities do not parse them correctly. Please see the attached model for a demo, it has a global macro #define FIVE 5. I try to pull resources off the list with the following queries:

  • WHERE Rank > FIVE - This does not match any items on the list
  • WHERE Rank > 5 - Replacing the macro by its definition works as expected
  • WHERE FIVE = 5 - Does not pull any items either. Interestingly enough, neither does WHERE FIVE = 0 so I don't know what FIVE evaluates to. Finally I observed that WHERE FIVE != 0 does pull an item.
FlexSim 16.0.1
process flowqueryglobal macros
querywithmacro.fsm (33.5 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Jordan Johnson avatar image
3 Likes"
Jordan Johnson answered Jordan Johnson edited

querywithmacro2.fsmThe issue here is that the list is trying to parse a statement that is part FlexScript, part SQL.

As an experiment, I added a node to my tools folder called testNode, and I gave it number data, with the value 5.0. I then changed the macro to #define FIVE node("Tools/testNode", model()). Then, I changed one of the pull queries to WHERE Rank > get(FIVE), and the pull worked.

This makes me believe that using gettablenum( SETTINGS_TABLE, SETTING_RUNTIME_NOW, SETTING_VALUE_COL ) in a query might work.

To answer your other question, FIVE is apparently evaluating to a null Variant value. In FlexScript, if you use the code var i = 5.0, you create a number Variant, with 5 as its value. Since a null Variant is not a number variant, a null Variant is not equal to, greater than, or less than a number. That is why the queries WHERE Rank > FIVE, WHERE 5 = FIVE, and WHERE FIVE = 0 do not match any values, while WHERE FIVE != 0 does.


querywithmacro2.fsm (28.5 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.