Topic
  • 8 replies
  • Latest Post - ‏2013-04-25T20:04:40Z by llandale
doorsuse
doorsuse
6 Posts

Pinned topic Exception Access Violation

‏2013-04-24T12:08:21Z |

Hi,

I am trying to create a choice box with the list of all object IDs. I am getting an excepton Acces Violation.

It would be great if anyone could point me to the error. The code:

 

Object Obj_object
Module tempmodule
tempmodule=current Module

DB reqBox = create "Edit Requirement"
string importance[100] //= {"Vital", "Useful",
                        // "Convenient", "Useless"}
 int k =0
for  Obj_object in tempmodule do
{
  importance[k]=Obj_object."Absolute Number" ""
 k++
}
DBE reqImport = choice(reqBox, "Importance: ", importance, 2)
 

void accept(DB reqBox)

{
    int i = get reqImport
    print importance[i]
} // accept


ok(reqBox, "Update LInks", accept)
show reqBox
 

  • llandale
    llandale
    3035 Posts

    Re: Exception Access Violation

    ‏2013-04-24T14:09:30Z  

    You need one more parameter on the choice, "initial selection"

    • DBE reqImport = choice(reqBox, "Importance: ", importance, 2, 1)

    -Louie

     

  • llandale
    llandale
    3035 Posts

    Re: Exception Access Violation

    ‏2013-04-24T14:33:17Z  

    If you figure a variable large number of rows (in this case, one for each object) a "list" would be better.  "choice" is for a small fixed number of choices.  Your callback "accept" needs to check for selection of "-1" which means "nothing selected".  The array of "choices" needs to be available when "realize" and "show" is executed; which almost always means it is a global array (like you have it).

  • doorsuse
    doorsuse
    6 Posts

    Re: Exception Access Violation

    ‏2013-04-24T15:31:54Z  
    • llandale
    • ‏2013-04-24T14:33:17Z

    If you figure a variable large number of rows (in this case, one for each object) a "list" would be better.  "choice" is for a small fixed number of choices.  Your callback "accept" needs to check for selection of "-1" which means "nothing selected".  The array of "choices" needs to be available when "realize" and "show" is executed; which almost always means it is a global array (like you have it).

    Hi,

     

    Thanks a lot for your response. I shall immediately give your suggestion a try and let you know.

    I have one more question. I want to know if the following is possible with DXL:

       I have created a choice  ("choice1") with a few options for the user to select. I want to create another choice ("choice2" )depending on the

       option the user selects in "choice1"

  • llandale
    llandale
    3035 Posts

    Re: Exception Access Violation

    ‏2013-04-24T16:55:02Z  
    • doorsuse
    • ‏2013-04-24T15:31:54Z

    Hi,

     

    Thanks a lot for your response. I shall immediately give your suggestion a try and let you know.

    I have one more question. I want to know if the following is possible with DXL:

       I have created a choice  ("choice1") with a few options for the user to select. I want to create another choice ("choice2" )depending on the

       option the user selects in "choice1"

    Nit-Pick: In the "Requirements Management", "shall" means you are obligated to do the action.  In your case you are just saying what you will do and should use "will".    lol

    Its rather complicated.  To use "choice" DBEs you'll need to

    • specify all the possible ones you want for Choice2, each arranged on top of each other.;  Each will ahve it's own DBE variable; dbeChoice2_0, dbeChoice2_1, ...
      • dbeChoice2_0 = ..
      • stacked(db)
      • dbeChoice2_1..
      • dbeChoice2_2
    • Have a callback on dbeChoice1 that gets the selection, the "show"s the version of dbeChoice you want and "hide"s the other.
      • void clbkChoice1(DBE dbeXX)
      • {  int Select = get(dbeChoice1)
      •    hide dbeChoice2_0
      •    hide dbeChoice2_1
      •    hide dbeChoice2_2
      •    if (Select == -1) then {}   // don't show any Choice2
      •    elseif (Select == 0) show(dbeChoice2_0)
      •    elseif (Select == 1) show(dbeChoice2_1)
      •    elseif(Select == 2) show(dbeChoice2_2)
      • }
      • set(dbeChoice1, clbkChoice1)

    -Louie

  • llandale
    llandale
    3035 Posts

    Re: Exception Access Violation

    ‏2013-04-24T17:10:32Z  
    • doorsuse
    • ‏2013-04-24T15:31:54Z

    Hi,

     

    Thanks a lot for your response. I shall immediately give your suggestion a try and let you know.

    I have one more question. I want to know if the following is possible with DXL:

       I have created a choice  ("choice1") with a few options for the user to select. I want to create another choice ("choice2" )depending on the

       option the user selects in "choice1"

    You could also define the various dbeChoice2_x next to each other and modify the clbkChoice1() to "inactive" all of them, then "active" the one you want.  Inactive DBEs will be grey'd out.

  • Johnny_P
    Johnny_P
    25 Posts

    Re: Exception Access Violation

    ‏2013-04-25T07:16:38Z  
    • doorsuse
    • ‏2013-04-24T15:31:54Z

    Hi,

     

    Thanks a lot for your response. I shall immediately give your suggestion a try and let you know.

    I have one more question. I want to know if the following is possible with DXL:

       I have created a choice  ("choice1") with a few options for the user to select. I want to create another choice ("choice2" )depending on the

       option the user selects in "choice1"

    Hi,

    in the past I always managed this sort of things like in the following example:

    DB dbX
    DBE dbeChoice1
    DBE dbeChoice2

    string sOptions[] = { "", "Option A", "Option B" }
    string sDummy[] = {}

    void insertDynamicChoices(int iOption)
    {
        int iIndex = null

        empty dbeChoice2 // delete all choice entries

        if (iOption == 0) {} // nothing
        elseif (iOption == 1)
        {
            for (iIndex=0;iIndex<=5;iIndex++)
            {
                insert(dbeChoice2, iIndex, "Dynamic option A - " iIndex"")
            }
        }
        elseif (iOption == 2)
        {
            for (iIndex=0;iIndex<=3;iIndex++)
            {
                insert(dbeChoice2, iIndex, "Dynamic option B - " iIndex"")
            }
        }
    }

    void callbackChoice1(DBE dbeChoice)
    {
        int iSelection = get(dbeChoice)
        insertDynamicChoices(iSelection)
    }

    dbX = create("Choice test", styleCentered)
    dbeChoice1 = choice(dbX, "Select your option:", sOptions, 0)
        set(dbeChoice1, callbackChoice1)
    dbeChoice2 = choice(dbX, "Dynamic options:", sDummy, 0)

    show dbX

    I simply create choice1 (fixed options) and choice2 (empty, dynamic options). Choice1 has a callback function that clears all entries in choice2 and inserts the new options.

     

    @Louie:

    Are there any Problems with my solution or advantages of using two stacked choice DBEs? Or is it just personal taste?

    Regards,

    Johnny

    Updated on 2013-04-25T07:18:35Z at 2013-04-25T07:18:35Z by Johnny_P
  • doorsuse
    doorsuse
    6 Posts

    Re: Exception Access Violation

    ‏2013-04-25T07:42:52Z  
    • Johnny_P
    • ‏2013-04-25T07:16:38Z

    Hi,

    in the past I always managed this sort of things like in the following example:

    DB dbX
    DBE dbeChoice1
    DBE dbeChoice2

    string sOptions[] = { "", "Option A", "Option B" }
    string sDummy[] = {}

    void insertDynamicChoices(int iOption)
    {
        int iIndex = null

        empty dbeChoice2 // delete all choice entries

        if (iOption == 0) {} // nothing
        elseif (iOption == 1)
        {
            for (iIndex=0;iIndex<=5;iIndex++)
            {
                insert(dbeChoice2, iIndex, "Dynamic option A - " iIndex"")
            }
        }
        elseif (iOption == 2)
        {
            for (iIndex=0;iIndex<=3;iIndex++)
            {
                insert(dbeChoice2, iIndex, "Dynamic option B - " iIndex"")
            }
        }
    }

    void callbackChoice1(DBE dbeChoice)
    {
        int iSelection = get(dbeChoice)
        insertDynamicChoices(iSelection)
    }

    dbX = create("Choice test", styleCentered)
    dbeChoice1 = choice(dbX, "Select your option:", sOptions, 0)
        set(dbeChoice1, callbackChoice1)
    dbeChoice2 = choice(dbX, "Dynamic options:", sDummy, 0)

    show dbX

    I simply create choice1 (fixed options) and choice2 (empty, dynamic options). Choice1 has a callback function that clears all entries in choice2 and inserts the new options.

     

    @Louie:

    Are there any Problems with my solution or advantages of using two stacked choice DBEs? Or is it just personal taste?

    Regards,

    Johnny

    I have done it almost the same way as Johnny has presented here. I found it easy and clean. 

    It would be helpful it Louie could point out the pros and cons of this method or as Johnny mentioned if it is just a personal taste.

     

    Btw thanks for the code Johnny, as i could take a few tips from your code.

  • llandale
    llandale
    3035 Posts

    Re: Exception Access Violation

    ‏2013-04-25T20:04:40Z  
    • Johnny_P
    • ‏2013-04-25T07:16:38Z

    Hi,

    in the past I always managed this sort of things like in the following example:

    DB dbX
    DBE dbeChoice1
    DBE dbeChoice2

    string sOptions[] = { "", "Option A", "Option B" }
    string sDummy[] = {}

    void insertDynamicChoices(int iOption)
    {
        int iIndex = null

        empty dbeChoice2 // delete all choice entries

        if (iOption == 0) {} // nothing
        elseif (iOption == 1)
        {
            for (iIndex=0;iIndex<=5;iIndex++)
            {
                insert(dbeChoice2, iIndex, "Dynamic option A - " iIndex"")
            }
        }
        elseif (iOption == 2)
        {
            for (iIndex=0;iIndex<=3;iIndex++)
            {
                insert(dbeChoice2, iIndex, "Dynamic option B - " iIndex"")
            }
        }
    }

    void callbackChoice1(DBE dbeChoice)
    {
        int iSelection = get(dbeChoice)
        insertDynamicChoices(iSelection)
    }

    dbX = create("Choice test", styleCentered)
    dbeChoice1 = choice(dbX, "Select your option:", sOptions, 0)
        set(dbeChoice1, callbackChoice1)
    dbeChoice2 = choice(dbX, "Dynamic options:", sDummy, 0)

    show dbX

    I simply create choice1 (fixed options) and choice2 (empty, dynamic options). Choice1 has a callback function that clears all entries in choice2 and inserts the new options.

     

    @Louie:

    Are there any Problems with my solution or advantages of using two stacked choice DBEs? Or is it just personal taste?

    Regards,

    Johnny

    Actually I hadn't considered the erase-re-create method.  The table-driven approach in your method can be matched by mine by putting the various Choice2 DBEs in an array{}.

    It seems 6 of one and half a dozen of the other.

    However, conceptually my method has the advantage if the various Choice2 lists are fundamentally different things and your method better if they are fundamentally the same thing, just different instances.  Things a "Dog" may do are different in nature than those of a "Spouse"; but the list of ladies for "Jim" to date may be different than for "Jack", but its still the same kind of list.  From a set-theory perspective, the particular list for Jim and for Jack all come from the same super-set of "Ladies", but the particular list for the Dog and the Spouse don't share a meaningful common super-set; a Dog does not "Drive" and a Spouse does not "Fetch".

    -Louie

    OK, so my spouse's spouse "Fetches" but lets not get into that.