Welcome to Phrogram Sign in | Join | Help
in Search


StringList Critical Errors

Last post 07-08-2008, 1:44 PM by The Dragon Rider. 3 replies.
Sort Posts: Previous Next
  •  07-07-2008, 5:11 PM 6862

    StringList Critical Errors

    Attachment: UserInputTest.kpl

    I'm attempting to write a player inventory for my games, and so far I can add and remove items by slot row# and column# ( basically an X/Y grid ). So far so good. But I need to be able to give the user a list of all the items he is holding, in alphabetical order, like so:

    Apple x5

    Dull Hairpin x1 

    Orange x2

    Shining Sword x1 

    etc.

    I have a method that does just that ( iInventory.List() ), but problems arise when trying to add new items and then list them again.

    So far I have gotten 3 System.ExecutionEngineException and a System.OutOfMemoryException and a "Error: Attempting to write to locked memory. This may indicate corrupted memory elsewhere." message. I rebooted after that one, but I still got the other 2. What's going on?

    The program should tell you how to use itself, but if you can't figure out how to do something, just ask. 

  •  07-07-2008, 9:31 PM 6863 in reply to 6862

    Re: StringList Critical Errors

    Do you have a set of add/remove/list that causes this. I crashed once but I was just playing around and now no matter what I can't get it to do it.

    I got the ExecutionEngineException


    Managed DirectX and XNA ? Check out http://www.thezbuffer.com
  •  07-08-2008, 1:33 PM 6870 in reply to 6863

    Re: StringList Critical Errors

    Yes, I use StringList.Add( item.Name ) to add them to the list, but I don't use remove because the StringList is only used inside method List(). Basically I add all of the inventory contents to the list. Next I sort the list. Lastly I cycle through and count the contents of the list, generate a string that reads "{Item name} x{# of times item appears in list}", ex

    'Dull Hairpin' x3 

    And then write the string to the console. 

    Because the list is generated inside the method, I don't use Remove(). 

  •  07-08-2008, 1:44 PM 6871 in reply to 6870

    Re: StringList Critical Errors

    I just noticed that I only get an error when the program messes up. Like so:

    Add 5 Shining Swords ([space])

    Press Home to list, it should say "Shining Sword x5".

    add something else named "Your Item", using PageUp.

    When I list the items again, it would say

    'Shining Sword' x4

    'Your Item' x1 

    and then crash. =/ 

     The method is at line 431, take a look and tell me if it's a coding mistake.
     

View as RSS news feed in XML