Syntax for argument with '|' seperator

robotm
robotm Germany
Hello,

for a procedure I need the possibility to combine two arguments with a OR character.
With optional arguments it works fine, but I don't wanna use optional arguments.


The following code is not accepted.
PROC SetValue(num Value<b>|</b>dnum Dvalue)
....
ENDPROC

I want the independence of the data type for calling SetValue.
VAR num Value;
VAR dnum Dvalue;

SetValue Value;<br>SetValue Dvalue;<br>


I found a code example in the manuel for the procedure SetGo.

This is the syntax from the robotware manuel "technical reference manual - RAPID Instructions, Functions and Data types" on page 688.
SetGO
[ '\' SDelay ':=' < expression (IN) of num > ',' ]
[ Signal ':=' ] < variable (VAR) of signalgo > ','
[ Value ':=' ] < expression (IN) of num >
| [ Dvalue' :=' ] < expression (IN) of dnum > ';'


I hope someone can help me.

Thanks in advance!

Comments

  • Hello,

    We've looked into this and because RAPID does not support overload you'll have to 'normalize' the variable before you call the function. With normalize I mean convert to either num or dnum.

    Consult the RAPID manual on how to do the conversion.

    Maxim Riabichev
    PC Software Support Engineer
  • soup
    soup USA ✭✭✭
    Interesting question! So, what kind of magic does the SetGO function have behind the scenes that it's able to do the num or dnum without conversion?
  • robotm
    robotm Germany
    Hello Maxim Riabichev,

    thank you for your response!

    I know the conversion function, but from a programmer's point of view it would be fantastic if two non-optional arguments could be combine with "or". 


    The SetGo command illustrates the advantages!


    I think it would be great if this possibility would be added in a future robotware update.
  • Hello,

    Okay I'll have a talk with my collegues tomorrow.

    Maxim Riabichev
    PC Software Support Engineer
  • Hello,

    So we've spoken about this matter and we've reached the conclusion that the best would be if RAPID would support Overload, like C# does for example.

    I will move this thread to the UpFeed section (as a suggestion for future addition to RAPID).

    Maxim Riabichev
    PC Software Support Engineer
  • robotm
    robotm Germany
    Hello,

    Glad to hear it.
    Thanks for everything.

    Kind regards