The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 return type "string"

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
datrix Posted - 08/24/2011 : 07:30:08 AM
Version: OriginPro 8.1G SR3 v8.1.34.90
Operating System: Windows XP SP3

Hello,

our institute uses the above mentioned Version of Origin and I have two little questions:

1. Problem with return type "string"

simple testcase:


string ReturnString(){
string a="abc";
out_str(a); // Output -> "abc" -> Works
return a;
}


compiles fine but after execution of ReturnString();
on error message appears:

ungültige Argumentanzahl an Funktion übergeben : 
#Command Error!


analogous translation: "invalid number of arguments delivered to function"
The message is not very helpful because the function "ReturnString()" does not have any arguments
What causes this error?

----------------------------

2. When a double click between two columns within a worksheet is performed (in the normal Origin GUI),
the column width exactly changes perfect to the width of the largest cell.
I would like to create the this effect with C++ code, but for example


...
wks.Columns(0).SetWidth();
...


creates not the same effect. How can I solve this problem?

Thanks
datrix
4   L A T E S T    R E P L I E S    (Newest First)
datrix Posted - 08/26/2011 : 09:51:48 AM
Thank you.

I think it is supported.
I can use all of those functions returning string and struct and all other types, when
enclosing it into a void function.

void vCall_openGUI(){

   GUIVALUES gv;
   gv = openGUI();

   if (gv.a == true/false){//do s.th.}
   if (gv.b == true/false){//do s.th.}
   if (gv.bGUICanceld == true/false){//do s.th.}
}

LT prompt:

>> vCall_openGUI() //<--- Will not create some error messages and works quite good.


I was just wondering why the error message is created when calling "openGUI()" directly.

greets
datrix
cpyang Posted - 08/25/2011 : 9:59:34 PM
1. return struct is probably not supported in Origin C, and you can easily pass in the struct by pointer or reference, like

bool openGUI(GUIVALUES & gv){
gv.a = tr.a.nVal;
return true;

}


2. bool is internally an int, so you can just use out_int for those.

CP
datrix Posted - 08/25/2011 : 07:05:24 AM
Hello Penn,

thank you for your answer.
For the string return it works now, but what about returning structs?

example: (Building small GUI with 2 checkboxes and return
the struct that catches the values the user set)



#include <Origin.h>
#include <GetNbox.h>

typedef	struct tagGUIValues{
	bool a;
	bool b;
	bool bGUICanceld;  
} GUIVALUES;


GUIVALUES openGUI(){
	
   GUIVALUES gv;
	
   // Build GUI 
   GETN_TREE(tr)
   GETN_CHECK(a, "Checkbox 1", false)
   GETN_CHECK(b, "Checkbox 2", true)
		
   // initialize GUI and read values into struct
   if(GetNBox(tr, "label text", "some other text")){
       gv.a = tr.a.nVal;
       gv.b = tr.b.nVal;
       gv.bGUICanceld = false;
       return gv;
   }

   else {
       gv.bGUICanceld = true;
       out_str("GUI canceld!");
       return gv;
   }
}


This is definetly corect code and compiles fine, runs fine, but creates the same
error message as with the "return string" example above.

-------------------------------------------

Another question concernig basic I/O operations
we have

out_int("number is = ",12); //for int
out_str("number is = 12"); // for strings
out_double("number is = ",12.00); //for double
out_tree ... // for trees

what about something like "out_bool();"
Does s.th. like this exists?

greets
datrix
Penn Posted - 08/24/2011 : 11:41:10 PM
Hi datrix,

For problem 1:
Maybe you have not called this Origin C function by using LabTalk statement correctly. I call this Origin C in LabTalk like:

string str$ = ReturnString()$;
str$ = ;

And it works fine. Here, the returned value needs to be assigned to a LabTalk variable, and the $ symbol is needed. You can find the related contents from the help document (Origin C>Programming Guide>Introduction to Origin C>Calling Functions>Calling Origin C from LabTalk>Returning Variables to LabTalk>Returning String).

For problem 2:
It is a bug and we will try to fix it. Thanks for reporting this.

Penn

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000