Opened 11 years ago

Closed 9 years ago

Last modified 9 years ago

#2483 closed defect (fixed)

function call with multiple output

Reported by: shish274@… Owned by: Martin Sjölund
Priority: high Milestone: 1.9.4
Component: Frontend Version: trunk
Keywords: Cc:

Description (last modified by Martin Sjölund)

function add 
  input Integer a; 
  input Integer b; 
  output Integer sum; 
  output Integer subtract; 
  output Integer multiply; 
algorithm 
  sum:= a+b; 
  if (a>b) then 
    subtract:= a-b; 
  else 
    subtract:= b-a; 
    multiply:= a*b; 
  end if; 
end add; 

if i want to get just the multiplication part of the result then i did

(,,mult) := add (3,4);

Also, (add,sub):= add (3,4) works fine
but when i want only subtraction part then it doesnt work
(,sub):= add (3.4);

Change History (16)

comment:1 by Martin Sjölund, 11 years ago

Description: modified (diff)

comment:2 by Martin Sjölund, 11 years ago

Component: OMEditFrontend

comment:3 by Martin Sjölund, 11 years ago

Owner: changed from me to Martin Sjölund
Status: newaccepted

comment:4 by Martin Sjölund, 11 years ago

r18159 fixes this for algorithms, but not equations.

comment:5 by shish274@…, 11 years ago

Even after installing the latest nightly build, i still get the same error "Type mismatch in assignment in (_, sub) := add(3, 4) of (#ANYTYPE#, Integer) := (Integer, Integer, Integer) "

comment:6 by Martin Sjölund, 11 years ago

Could you show a more complete example? Because the following does work for me:

function add 
  input Integer a; 
  input Integer b; 
  output Integer sum; 
  output Integer subtract; 
  output Integer multiply; 
algorithm 
  sum:= a+b; 
  if (a>b) then 
    subtract:= a-b; 
  else 
    subtract:= b-a; 
    multiply:= a*b; 
  end if; 
end add; 

model M
  Real x;
algorithm
  (,x) := add(1,2);
end M;

comment:7 by anonymous, 11 years ago

function add

input Integer a;
input Integer b;
output Integer sum;
output Integer subtract;
output Integer multiply;

algorithm

sum:= a+b;
if (a>b) then

subtract:= a-b;

else

subtract:= b-a;

end if;
multiply:= a*b;

end add;

model call
Integer sub;
algorithm
(,sub):= add(3,4);
end call;

It looks the same but its not working for me.. i dont know why

comment:8 by Martin Sjölund, 11 years ago

Do omc ++v or getVersion() to check the exact revision of omc you are using. Your code is working for me.

in reply to:  8 comment:9 by anonymous, 11 years ago

Replying to sjoelund.se:

Do omc ++v or getVersion() to check the exact revision of omc you are using. Your code is working for me.

I tried installing r18160 but now the same code is not simulating...i deleted the files in folder in Temp/OpenModelica/OMEdit....i also tried changing the name of the function :(

ERROR:
"Process crashed
Simulation process exited with code -1073741819"

"Scripting 16:11:19 0:0-0:0 Failed to open simulation result C:/Users/SHRES_~1/AppData/Local/Temp/OpenModelica/OMEdit/funcall_res.mat: Too few rows in data_2 matrix"

comment:10 by anonymous, 11 years ago

I dont get any error after i installed the revision 18219. Thanks !

comment:11 by Martin Sjölund, 10 years ago

Milestone: 1.9.11.9.2

This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).

comment:12 by Martin Sjölund, 10 years ago

Milestone: 1.9.21.9.3

Milestone changed to 1.9.3 since 1.9.2 was released.

comment:13 by Martin Sjölund, 9 years ago

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

comment:14 by Per Östlund, 9 years ago

Resolution: fixed
Status: acceptedclosed

comment:15 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:16 by Martin Sjölund, 9 years ago

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.