Jump to content
OMRON Forums

Invoking Macros


DaveBarnett

Recommended Posts

All..

 

After I learned that PowerPmac IDE will add your global definitions to the intellisense namespace that are then available to the parser...(and even works under GPASCII, without the IDE) I began to understand what a handy tool this is to have in the debugging arsenal!

 

For example...I can add to the global definitions:

 

#define MyCmd1 P10=10

 

and, after download, this will appear in the intellisense context if using the IDE terminal, and you can type the cmd in a GPASCII session over Ethernet, and it works.

 

But, what I’m wondering,..is it possible to actually call a function this way...and pass and return parameters? That would be “the bomb” !, as my kids say.

 

From the manual:

** Function text substitution macros, single-line or multi-line, can only be invoked from within a downloaded IDE project. Unlike single-line macros, they cannot be invoked from command lines such as the IDE terminal window or other gpascii -2 communications threads **

 

Is there another way...? I’ve experimented with Python scripts doing the parsing...but, it's slow and involves managing the write-protected memory, etc.

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

This requires the “parsing” of the IDEs pre-processor to “build” the function-like code. PMAC syntax only knows: call 10000

 

User-specified program within IDE project manager:

open subprog Pythag (Rise, Run, &Hypot)

local RiseSqrd, RunSqrd;

RiseSqrd = Rise * Rise;

RunSqrd = Run * Run;

Hypot = sqrt(RiseSqrd + RunSqrd);

close

 

Automatically becomes for download:

#define Pythag {auto-assigned #}

open subprog Pythag // open subprog {auto-assigned #}

#define Rise L0 // First variable in subprogram declaration

#define Run L1 // Second variable in subprogram declaration

#define Hypot L2 // Third variable in subprogram declaration

#define RiseSqrd L3 // First internally declared local variable

#define RunSqrd L4 // Second internally declared local variable

RiseSqrd = Rise * Rise; // L3 = L0 * L0;

RunSqrd = Run * Run; // L4 = L1 * L1

Hypot = sqrt(RiseSqrd + RunSqrd); // L2 = sqrt(L3 + L4);

close

 

Subroutine call statement in calling program written as

call Pythag (XDist, YDist, &VecDist);

 

Automatically becomes for download:

R0=XDist; R1=YDist; call Pythag; VecDist=R2;

Pythag is substituted by {auto-assigned #}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...