![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Dynamic display of columns in a dialog Box Topic Summary: Created On: 21-Nov-2003 15:39 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() Answer: Srikanth, Try the attached code. You can create an array of DBE's and stop doing 30 separate tests. Also, the maximum number of columns allowed in a view is 31, therefore I defined MAX_COLS to be 31. -Dennis | |
![]() |
|
Hi All,
I am trying to create a dialog box which would enable the users to enter Objects. I am getting the column names and displaying them as text labels in dialog box. That works fine. I am having problem when I try to read those text values using the get command. Any help is appreciated. Here is the code that works : (Pleae scroll down to find the same version of the code that does not work) void hideerrorw(DB errorw) { hide(errorw) } DB errorw = centered "Object Entry" DBE field1 = field(errorw, "Column title1", "", 100) DBE field2 = field(errorw, "Column title2", "", 100) DBE field3 = field(errorw, "Column title3", "", 100) DBE field4 = field(errorw, "Column title4", "", 100) DBE field5 = field(errorw, "Column title5", "", 100) DBE field6 = field(errorw, "Column title6", "", 100) DBE field7 = field(errorw, "Column title7", "", 100) DBE field8 = field(errorw, "Column title8", "", 100) DBE field9 = field(errorw, "Column title9", "", 100) DBE field10 = field(errorw, "Column title10", "", 100) void routine(DB errorw) { string input1 = get field1 string input2 = get field2 string input3 = get field3 string input4 = get field4 string input5 = get field5 string input6 = get field6 string input7 = get field7 string input8 = get field8 string input9 = get field9 string input10 = get field10 print "input1 " input1 "\n" print "input2 " input2 "\n" } apply(errorw, "Add Record", routine) close(errorw, true, hideerrorw) show(errorw) Here is the code that does not work. The DXL Interpreter somehow does not like the DBE statements to be in a loop void hideerrorw(DB errorw) { hide(errorw) } DB errorw = centered "Object Entry" Column c int i = 1 Module m = current for c in m do { if (i==1) {DBE field1 = field(errorw, title(c), "", 100)} if (i==2) {DBE field2 = field(errorw, title(c), "", 100)} if (i==3) {DBE field3 = field(errorw, title(c), "", 100)} if (i==4) {DBE field4 = field(errorw, title(c), "", 100)} if (i==5) {DBE field5 = field(errorw, title(c), "", 100)} if (i==6) {DBE field6 = field(errorw, title(c), "", 100)} if (i==7) {DBE field7 = field(errorw, title(c), "", 100)} if (i==8) {DBE field8 = field(errorw, title(c), "", 100)} if (i==10) {DBE field10 = field(errorw, title(c), "", 100)} i++ } void routine(DB errorw) { string input1 = get field1 string input2 = get field2 string input3 = get field3 string input4 = get field4 string input5 = get field5 string input6 = get field6 string input7 = get field7 string input8 = get field8 string input9 = get field9 string input10 = get field10 } apply(errorw, "Add Record", routine) close(errorw, true, hideerrorw) show(errorw) Thank you Srikanth |
|
![]() |
|
![]() |
|
You are defining your DBE variables out of context. If you define a variable inside a set of braces {} (or a single if/else/or some Loop statement), it no longer exists OUTSIDE the braces. That's why variables declared in a function cannot be used OUTSIDE the function. Your DBEs need to be defined in the MAIN program. This "variable context" feature is common to almost all programming languages.
int i = 1 if (true) {int i = 2} print i // prints "1" whereas: int i = 1 if (true) i = 2} print i // prints "2" In your case, try: DBE Field1= null DBE Field2 = null etc for c in mod do { if (i==1) Field1 = field(..) etc } void routine { if (!null Field1) input1 = get(Field1) else input1 = "" etc. } - Louie On a side note, this feature creates problems if you want to defined an global array at a particular size; perhaps to hold the Enumerations of a particular attribute. You need to calculate the "size" in the MAIN program before you can declare the Array, also in the MAIN. It really clutters things up badly, since the routines to calculate the size need to come before the Array declaration, which needs to come before the functions that depend on it. |
|
![]() |
|
![]() |
|
Louie, Firstly I would like to thank you for your valuble Help. Now coming to my issue. Here is the reason I have not defined DBE's as null in my main program. The get command I used later is getting me the null values instead of the values it is supposed to get from the DBE's in the loop. How do I get around this situation? Here is my modified code.
void hideerrorw(DB errorw) { hide(errorw) } DB errorw = centered "Test Case Failure entry" DBE field1 = null DBE field2 = null DBE field3 = null DBE field4 = null DBE field5 = null DBE field6 = null DBE field7 = null DBE field8 = null DBE field9 = null DBE field10 = null DBE field11 = null DBE field12 = null DBE field13 = null DBE field14 = null DBE field15 = null DBE field16 = null DBE field17 = null DBE field18 = null DBE field19 = null DBE field20 = null DBE field21 = null DBE field22 = null DBE field23 = null DBE field24 = null DBE field25 = null DBE field26 = null DBE field27 = null DBE field28 = null DBE field29 = null DBE field30 = null Column c int i = 1 Module m = current string titlec for c in m do { titlec = title(c)" "i":" if (i==1) {DBE field1 = field(errorw, titlec, "", 100)} if (i==2) {DBE field2 = field(errorw, titlec, "", 100)} if (i==3) {DBE field3 = field(errorw, titlec, "", 100)} if (i==4) {DBE field4 = field(errorw, titlec, "", 100)} if (i==5) {DBE field5 = field(errorw, titlec, "", 100)} if (i==6) {DBE field6 = field(errorw, titlec, "", 100)} if (i==7) {DBE field7 = field(errorw, titlec, "", 100)} if (i==8) {DBE field8 = field(errorw, titlec, "", 100)} if (i==9) {DBE field9 = field(errorw, titlec, "", 100)} if (i==10) {DBE field10 = field(errorw, titlec, "", 100)} if (i==11) {DBE field11 = field(errorw, titlec, "", 100)} if (i==12) {DBE field12 = field(errorw, titlec, "", 100)} if (i==13) {DBE field13 = field(errorw, titlec, "", 100)} if (i==14) {DBE field14 = field(errorw, titlec, "", 100)} if (i==15) {DBE field15 = field(errorw, titlec, "", 100)} if (i==16) {DBE field16 = field(errorw, titlec, "", 100)} if (i==17) {DBE field17 = field(errorw, titlec, "", 100)} if (i==18) {DBE field18 = field(errorw, titlec, "", 100)} if (i==19) {DBE field19 = field(errorw, titlec, "", 100)} if (i==20) {DBE field20 = field(errorw, titlec, "", 100)} if (i==21) {DBE field21 = field(errorw, titlec, "", 100)} if (i==22) {DBE field22 = field(errorw, titlec, "", 100)} if (i==23) {DBE field23 = field(errorw, titlec, "", 100)} if (i==24) {DBE field24 = field(errorw, titlec, "", 100)} if (i==25) {DBE field25 = field(errorw, titlec, "", 100)} if (i==26) {DBE field26 = field(errorw, titlec, "", 100)} if (i==27) {DBE field27 = field(errorw, titlec, "", 100)} if (i==28) {DBE field28 = field(errorw, titlec, "", 100)} if (i==29) {DBE field29 = field(errorw, titlec, "", 100)} if (i==30) {DBE field30 = field(errorw, titlec, "", 100)} i++ } void adrout(DB errorw) { string input1 = "" if (null field1){input1 = get(field1)} else {input1 = ""} print input1 } apply(errorw, "Add Record", adrout) close(errorw, true, hideerrorw) show(errorw) |
|
![]() |
|
![]() |
|
Srikanth,
Try the attached code. You can create an array of DBE's and stop doing 30 separate tests. Also, the maximum number of columns allowed in a view is 31, therefore I defined MAX_COLS to be 31. -Dennis |
|
![]() |
|
![]() |
|
Thanks a Lot to Dennis and Louie.
|
|
![]() |
|
![]() |
|
I didn't run it but Lockshine's solution looks good. Your second set of DXL, I notice, double declared the DBEs: in the "if (i=x)" statements, remove the "DBE" statements.
- Louie |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Dynamic display of columns in a dialog Box
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.