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