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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Using two GETNBOX?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

winflowers

USA
34 Posts

Posted - 09/19/2007 :  10:25:53 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): Origin 7.5 SR6
Operating System: XP

I would like to construct a dialog with two string list boxes. But the list of the second list box is based on the selection of the first list box. For example,
...
GETN_LIST(Name, "1st", 0, "AA|BB|CC")
if(tr.Name.strVal == "AA") strList = "a1|a2|a3";
if(tr.Name.strVal == "BB") strList = "b1|b2|b3";
if(tr.Name.strVal == "CC") strList = "c1|c2|c3";
GETN_LIST(AName, "2nd", 0, strList)
...

After searching the forum, I realized that it is not possible to dynamically change the existing nodes.(Please correct me if I am wrong.) Then I decided to use 2 GETNBOXs. In the first GETNBOX, create the strList for the second list box according to the selection. But when I tried to compile it, I always got an error "Error, duplicate variable names in declaration: _tmpNode". I have no idea how to solve it. I also tried tr.Reset() and GETN_USE(tr), but neither worked.

I need help from you. Thanks a lot!

Mike Buess

USA
3037 Posts

Posted - 09/19/2007 :  12:15:50 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
First of all, string list nodes have numeric rather than string values, so tr.Name.nVal and tr.Name.strVal are both 0,1 or 2. Therefore, none of your IF conditions are true. That said, instead of using two dialogs (if that's even possible) it would be much easier to create all three list nodes and hide those you don't want...
void run_nested_string_lists()
{
string strA = "a1|a2|a3";
string strB = "b1|b2|b3";
string strC = "c1|c2|c3";
GETN_TREE(tr)
GETN_LIST(Name, "1st", 0, "AA|BB|CC")
GETN_LIST(AName, "2nd", 0, strA)
GETN_LIST(BName, "2nd", 0, strB)
GETN_LIST(CName, "2nd", 0, strC)
if( GetNBox(tr, "Nested String Lists", NULL, NULL, DialogOnChangeEvent) )
{
string strOut;
if( tr.Name.nVal==0 ) strOut = strA.GetToken(tr.AName.nVal,'|');
if( tr.Name.nVal==1 ) strOut = strB.GetToken(tr.BName.nVal,'|');
if( tr.Name.nVal==2 ) strOut = strC.GetToken(tr.CName.nVal,'|');
out_str(strOut);
}
}
bool DialogOnChangeEvent(TreeNode& tr, int nRow, int nType, Dialog& Dlg)
{
if( nType==TRGP_STR_LIST )
{
tr.AName.Show = tr.Name.nVal==0 ? true : false;
tr.BName.Show = tr.Name.nVal==1 ? true : false;
tr.CName.Show = tr.Name.nVal==2 ? true : false;
return true;
}
else
return false;
}


Mike Buess
Origin WebRing Member
Go to Top of Page

winflowers

USA
34 Posts

Posted - 09/20/2007 :  05:28:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you, Mike!

You are right. The sting list nodes only have numeric values, but the COMBO nodes have string values. I was a little confused about their description in the help file.

Your codes work well, but just a little bit complicate beacause I have more items in the first list, and each item need two string list nodes. That means I have to create dozen of list nodes at the beginning. Are there any better ways?

I am still interested in how to use two GETNBOX in one function in case I need it in the future. Could you please give me an example? I could not find it in the help file.

By the way, what the difference between GETN_BOX and GETN_TREE? When should we use GETN_BOX and when GETN_TREE?

Thank you very much for your assistance!
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/20/2007 :  09:26:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
I am still interested in how to use two GETNBOX in one function in case I need it in the future. Could you please give me an example?
I don't think it's possible for one GETNBOX to call another.

quote:
what the difference between GETN_BOX and GETN_TREE?
They just create slightly different styled dialogs. You can compare yourself.

Mike Buess
Origin WebRing Member
Go to Top of Page

winflowers

USA
34 Posts

Posted - 09/20/2007 :  09:50:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:

quote:
I am still interested in how to use two GETNBOX in one function in case I need it in the future. Could you please give me an example?
I don't think it's possible for one GETNBOX to call another.


I don't mean to call one GETNBOX in another, just one after another. The first is finished, then another one. There is no relationship between them. As I said in the first post: I always got an error "Error, duplicate variable names in declaration: _tmpNode". I think it should be possible, but don't know how to do it.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/20/2007 :  10:14:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Should work if you create the 2nd GETNBOX in a different function...

if( GETNBOX(...) )
{
string strList;
if( tr.Name.nVal==0 ) strList = "a1|a2|a3";
if( tr.Name.nVal==1 ) strList = "b1|b2|b3";
if( tr.Name.nVal==2 ) strList = "c1|c2|c3";
if( !strList.IsEmpty() ) DoNextBox(strList);
}

void DoNextBox(string strList)
{
// Create 2nd GETNBOX
}

Mike Buess
Origin WebRing Member
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000