DaveBarnett Posted July 9, 2018 Share Posted July 9, 2018 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 More sharing options...
steve.milici Posted July 10, 2018 Share Posted July 10, 2018 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 More sharing options...
DaveBarnett Posted July 12, 2018 Author Share Posted July 12, 2018 Thanks, Steve. I see how you can create these sub programs for use with PLC's and motion programs. But, how to get the functionality over the GPASCII session? (If I type Pythag(....) into the terminal, it is rejected as illegal) Link to comment Share on other sites More sharing options...
steve.milici Posted July 12, 2018 Share Posted July 12, 2018 In "gpascii" only valid PMAC syntax is allowed. Link to comment Share on other sites More sharing options...
Recommended Posts