Author Topic: IRD 7.5 subroutines I/O parameters, how did they work ?  (Read 5936 times)

Offline Gef Buneri

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: 0
  • Madness is just a point of view.
IRD 7.5 subroutines I/O parameters, how did they work ?
« on: June 19, 2014, 02:06:02 PM »
Hi all again,
I'm using subroutines in IRD with the call subroutine block and to transfer parameters from main apllication to subroutine, I'm using the attach/update method, but I noticed the input and output parameters in the block, so I would like to understand exactly how did they work.

I can use them to mantain a local variable continuity ? i.e., If I must pass the ANI[] value from main app to sub, can I just create a local variable in the main app, popolate it with the ANI[] function, then assign it as an input parameter for the sub call ? And to use back the value from the sub to the main app, assign it in the out parameters of the sub ?

Hope I was able to explain my doubt.


Another question... what exactly did the function "backup", "restore" and "restore from temp" of the IRD app do ? (at the moment I store strategies in a DB).

Regards,


Gef.
« Last Edit: June 19, 2014, 02:31:30 PM by Gef Buneri »

Offline mduran22

  • Full Member
  • ***
  • Posts: 108
  • Karma: 5
Re: IRD 7.5 subroutines I/O parameters, how did they work ?
« Reply #1 on: June 19, 2014, 05:12:14 PM »
Hi Gef,

That is correct, you can pass variables into the subroutine from the strategy out of the subroutine back to the strategy. When you create a subroutine it asks you for this input and output parameters. If you need to add more later you can do so using describe under file. If you look at your variable list, the ones you add this way will show up under the input/output column as the type you set them up as.

Your example of ANI is one way this can be used, although you would only need pass it in the output parameter if you changed it (it would still be the same in the main strategy. Perhaps a better example would be if you had an account number as a variable in your main strategy, then you called a subroutine that you passed that account number variable to, used it to determine something about the account, lets say region and account level (Northwest/Gold) and assigned those as variables in the subroutine, then you would use the output parameters to assign those to variables in the main routing strategy for use there.

The backup option is a version control type feature where you can save different versions of your strategy and the restore a specific version (kind of like a code store repository). Also in the routing design options, storage settings tab, you can set an autosave timer that will backup strategy or subroutine ever X min based on what you specify. If IRD or you computer locks up or crashes, you can use the restore from temp to restore the last autosave version of the strategy/subroutine. I don't know how many people actually use this feature (and I don't remember training having an emphasis on it). Most of the developers I have run across just save the strategy/subroutine with a different name as a back up.

Mike

Offline terry

  • Sr. Member
  • ****
  • Posts: 328
  • Karma: 35
Re: IRD 7.5 subroutines I/O parameters, how did they work ?
« Reply #2 on: June 19, 2014, 05:29:50 PM »
Maybe couple of extra things:
- in 8.x there are shared variables - they are visible/accessible from inside any strategy/subroutine running for the same call.
- all backup versions of strategies are stored within the same rbn file (and version with name "current" is one IRD shows/edits when strategy is opened). 

Offline Gef Buneri

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: 0
  • Madness is just a point of view.
Re: IRD 7.5 subroutines I/O parameters, how did they work ?
« Reply #3 on: June 20, 2014, 07:08:47 AM »
So kind of you, Mark. Your answer was really useful and exhaustive.

Tank you very much. Tank to you too, Terry.


Regards.

**EDIT**
Just a doubt... in case of a null ( i mean empty '') variable from main app to sub or viceversa, will be generated an exception to cause the sub call failure, or just will be used a null value ?
« Last Edit: June 20, 2014, 07:26:33 AM by Gef Buneri »

Offline terry

  • Sr. Member
  • ****
  • Posts: 328
  • Karma: 35
Re: IRD 7.5 subroutines I/O parameters, how did they work ?
« Reply #4 on: June 20, 2014, 02:53:32 PM »
Empty string value will be used ('' everewhere considered as "normal" string value and its usage never raise exception because of fact of its emptiness) 

Offline Gef Buneri

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: 0
  • Madness is just a point of view.
Re: IRD 7.5 subroutines I/O parameters, how did they work ?
« Reply #5 on: June 24, 2014, 07:53:55 AM »
Thanx again, Terry.

Offline Gef Buneri

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: 0
  • Madness is just a point of view.
Re: IRD 7.5 subroutines I/O parameters, how did they work ?
« Reply #6 on: June 26, 2014, 07:25:52 AM »
Here I am again... sorry.

After some tests, there's something I can't correctly figure out. i.e., I can't use the same variable name for input and output, in the sub I/O. So if I would to guarantee the continuity of a variable, which method should I use ?

I mean, if I would to pass a variable from main app to sub, I use that variable in the sub as input variable, but then ? I have to create a new variable to send back the value to the main app ? So I have the CLI var in main app, i.e., I send it to the sub creating a "CLI" input variable, then I have to traslate to a "CLI_O" sub output variable and create a "CLI_O" variable in the main app to receive the value ?

Quite lost :)

Regards.

***EDIT***
As I see, the only quite optimal way to approach the goal seems to be an hybrid approach; creating in the sub a new set of variable like var%_i, then an attach data of the variable value from the main, an update of the value to the var%_i in the sub, a migration from the var%_i to the var% name, then set as output variable the var with the same name of the main app... seems really tricky, I'm doing something wrong here, cause I/O var in the sub seem useless.
« Last Edit: June 26, 2014, 07:46:38 AM by Gef Buneri »

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: IRD 7.5 subroutines I/O parameters, how did they work ?
« Reply #7 on: June 26, 2014, 02:03:07 PM »
IRD variables are local only. I believe that on IRD 8 there is an option for global variables.
If using 7.5 still the variables, as said, will stay only on the current strategy (sub or not). So in order to pass and return variables you need to do a variable match, probably same names if you want. There is no way that a sub-routine to read/write a routine or another sub-routine variables.

Offline terry

  • Sr. Member
  • ****
  • Posts: 328
  • Karma: 35
Re: IRD 7.5 subroutines I/O parameters, how did they work ?
« Reply #8 on: June 26, 2014, 06:56:26 PM »
In 7.x something like that:
Subroutine has CLI input and CLI_O output parameter.
In subroutine just before returning back (just before Return block) make assignment CII_O = CLI.

In main strategy use CLI variable when invoking subroutine: 
    for subroutine CLI input paraneter and
    for subroutine CLI_O output parameter.
It will result :
  At the moment of calling subroutine value in main's CLI will be automatically copied into subroutine's CLI,
  At moment of return - value of subroutine CLI_O (which is the same as CLI) will be automatically copied back into
  main CLI. 


Offline Gef Buneri

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: 0
  • Madness is just a point of view.
Re: IRD 7.5 subroutines I/O parameters, how did they work ?
« Reply #9 on: June 30, 2014, 10:31:25 AM »
Ok, I've to work this thing a while to see how it works better, using your tips.

Thank you very much again Terry, an Cavagnaro.


Regards.