Jump to content
OMRON Forums

Call subprogram with online command


andyf
 Share

Recommended Posts

I have a subprogram in the library that contains several subprograms within it. Is there a way to call one of these from the IDE terminal with online commands? The help seems to indicate that "call" and "callsub" are valid online commands, but they do not work.

 

Example:

 

call mylib.mylibsub()

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi, ..

 

I think you can use "cx" or "cpx" on-line command.

 

You cannot use "call" or "callsub" command directly in terminal.

As I know, it's a buffer program command ( can only be used in prog or subprog or plc script )

 

So, you have to use "cx" or "cpx" command to execute "call".

 

"cx" is a command that can execute plc command in terminal.

"cpx" is a command that can execute prog command in terminal.

 

And one thing to keep in your mind is that,

compiler is not working in the on-line command.

 

for example there are subprog below.

 

open subprog AddData(data1, data2, &result)

result = data1+data2

close

 

and you can call subprogram in motion prog or plc like below.

 

open plc 1

local data1, data2, result;

data1 = 3

data2 = 4

call AddData(data1, data2, &result)

P1 = result

disable plc 1

close

 

you can use "call AddData(data1, data2, &result)" in the buffer program.

but can not use in the terminal because there's no compile action.

 

So you must use L & R variables to use subprogram with arguments.

 

in terminal.

 

cx R0=3;R1=4;call AddData;P1=R2

 

then, you can read the result in P1 variable.

 

P1 = 7

 

I hope this helps.

Link to comment
Share on other sites

Thank you. Yes this does help, and I was able to run an example like your using cpx and a subprogram. However, it seems I am not able to call a sub program within a sub program, which is something I can normally do in a motion program.

 

For example, if the subprogram in my library is like that shown below, I cannot do:

 

cpx R0=3; call testsub.testsubinside; P1=R1;

 

 

Example:

 

open subprog testsub

return;

 

sub: testsubinside(input, &output)

output = input + 2;

return;

 

close

Link to comment
Share on other sites

Hi, andyf.

 

As I said before... there's no compile action in terminal.

 

And you can check your subprogram in terminal.

 

if you list your subprog in terminal, there's response like below.

 

list subprog testsub

 

return;

n10000:

L1=L0+2

return

 

As you see, "testsubinside" tag is changed to "n10000".

so you can use like this.

 

cx R0=3; call testsub.01; P1=R1;

 

This is all I know about subprogram call in terminal.

 

Anyone who know more about this subject, please tell us in more detail.

 

Thanks.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...