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 two values from C function

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
peter.cook Posted - 01/28/2004 : 2:48:10 PM
HI,

Can I return multiple values from an Origin C function via Labtalk
eg I can set up

typedef struct {

string StringValue;
double RowValue;

} FindRowAndString;

FindRowAndString OCFindValueFromSheet(string WSName, int ForCol, int FromCol, string MatchString, int NumRows)
{
Worksheet wks(WSName);
string Forstring;
string Fromstring;

FindRowAndString ResultsOut;
ResultsOut.StringValue="NULL";
ResultsOut.RowValue=0;

for(int NumRow=1; NumRow<=NumRows; NumRow++) {
wks.GetCell(NumRow-1,ForCol-1,Forstring);
if(Forstring.CompareNoCase(MatchString)==0) {
wks.GetCell(NumRow-1,FromCol-1,Fromstring);
ResultsOut.StringValue=Fromstring;
ResultsOut.RowValue=NumRow;
break;
};
};

return ResultsOut;
}


and obtain either OCFindValueFromSheet.StringValue or OCFindValueFromSheet.RowValue with another C function eg

int trip()
{

int temp;
temp=OCFindValueFromSheet("HTSSIniFile",1,2,"Expt_Date",20).RowValue;
return temp;

}


thus trip()= returns 12.

Can I return eg StringValue and RowValue in LabTalk without running OCFindValueFromSheet twice?


Cheers,

Pete


Edited by - peter.cook on 01/28/2004 2:49:14 PM
3   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 01/29/2004 : 7:41:21 PM
passing variables from OC back to LT was added in 70 SR4. LT_set_var etc was in the original support when OC was first started.

Ee have been adding support for passing various things between OC and LT such that LT can be extended via OC functions, to make LT more like MATLAB, so to speak.

CP


peter.cook Posted - 01/29/2004 : 6:13:08 PM
Hi CP,

Thanks for this (and others) reply. Am I missing something here? I've always used LT_set_var to pass values back to LabTalk variables. Is this not necessary as per your example then?

Cheers,

Pete

cpyang Posted - 01/28/2004 : 6:10:20 PM
Hi Peter,

Would it be good enough to just pass values back to LT?, see below
 
// append str with number,
// then increment number
void dd(string& str, double& var)
{
str += var;
var *= 2;
}




Then in LT,

aa$=junk;xx=1;
dd aa$ xx;
aa$=; xx=;


and you should see string and numeric variables both pass back from OC into LT


CP



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