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
 structures

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
mkoetse Posted - 02/03/2004 : 5:30:06 PM
Hello,

Could anyone tell me where I could find some more information (e.g. on the web) on using structures in (origin)C. I never used them before, and I'd like to learn how use of them.

Regards,

Marc

2   L A T E S T    R E P L I E S    (Newest First)
mkoetse Posted - 02/04/2004 : 02:24:57 AM
Thanx,

But this is a few levels of programming ahead of where I'm standing right now, I'm afraid:)

MMK

cpyang Posted - 02/03/2004 : 7:43:57 PM
You can read about struct in any standard C or C++ books. I just want to point out that Origin C has support for Tree and any branch of a tree can be assigned to a struct and vice versa.

This will allow low level functions to be written using struct as argument, to conform to standard C, and higher level functions can keep parameters in a tree and just pass branches of a tree into a low level C function via a struct.

The following code shows how this works,



#include <Origin.h>
#include <GetNBox.h>

// good to typdef a struct before using it
typedef struct tagTest
{
bool readOnly;
char filename[MAXFULLPATH];
} myStructTest;


// event handler for button in GetNBox to open File dialog
static bool get_file_name_handler(TreeNode& myTree, int nRow, int nCntrlType, Dialog& getNDlg)
{
string str = GetOpenBox("*.TXT Text file", GetAppPath());
myTree.filename.strVal = str;
return true;
}

void test_tree_to_struct()
{
GETN_TREE(myTree)
// make sure tree node tagName identical to struct member name
GETN_CHECK(readOnly, "Read Only", false)
GETN_BUTTON(filename, "File name", "c:\\test.txt")
GETN_OPTION_EVENT(get_file_name_handler)

if(GetNBox(myTree, "Save As", "Save some info into a file"))
{
myStructTest fInfo; // declare struct on stack
fInfo = myTree; // direct assignment from treenode to matching struct

printf("file = %s, read only = %d\n", fInfo.filename, fInfo.readOnly);
}
}




CP



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