Results 1 to 12 of 12

Thread: Way over my head - stuck on this one...

  1. #1

    Thread Starter
    Hyperactive Member Petergotchi's Avatar
    Join Date
    Jan 2002
    Location
    Dendermonde - Belgium
    Posts
    267

    Way over my head - stuck on this one...

    Let's say you have this in a textfile
    Code:
    1.0
    1.1
    1.1-2.0
    1.1-2.1
    1.2
    1.2-2.0
    1.2-2.1
    1.2-2.2
    1.3
    So in this example 1.1-2.0 and 1.1-2.1 are dependant on 1.1

    I want to be able to delete a row from this text file but I need to rebuild it correctly again.

    Deleting 1.1 now leads to this: (that's how far I got)
    Code:
    1.0
    1.2
    1.2-2.0
    1.2-2.1
    1.2-2.2
    1.3
    As you can see, 1.2 doesn't follow up 1.0 and so my app crashes...

    The right output would be:
    Code:
    1.0
    1.1
    1.1-2.0
    1.1-2.1
    1.1-2.2
    1.2
    It's getting a bit to difficult for me. My brains are starting to boil.

    Does somebody know how to write the procedure to do that last thing I explained?
    Pls help me on this one...

    Thx a lot allready...
    Kind Regards,

    Pieter

    PS: If you found someone's answer helpful, please be so kind to rate that person.
    Thanks.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    huh? Your post is full of contradictions! You say delete 1.1 but you say 1.1 should still be there? You said 1.2 doesnt follow 1.0 but in your example it does?
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Hyperactive Member Petergotchi's Avatar
    Join Date
    Jan 2002
    Location
    Dendermonde - Belgium
    Posts
    267
    The original 1.1 and follow ups get deleted
    And the 1.2 and follow ups become 1.1...
    Get it or do I have to give a more precise example?
    Kind Regards,

    Pieter

    PS: If you found someone's answer helpful, please be so kind to rate that person.
    Thanks.

  4. #4

    Thread Starter
    Hyperactive Member Petergotchi's Avatar
    Join Date
    Jan 2002
    Location
    Dendermonde - Belgium
    Posts
    267
    Let's say you have this in a textfile

    Code:
    1.0: Choice 1 without followups
    1.1: Choice 2 with 2 followups
    1.1-2.0: 1st followup of choice2
    1.1-2.1: 2nd followup of choice2
    1.2: Choice 3 with 3 followups
    1.2-2.0: 1st followup of choice3
    1.2-2.1: 2nd followup of choice3
    1.2-2.2: third followup of choice3
    1.3: Choice 4 without followups
    So in this example 1.1-2.0 and 1.1-2.1 are dependant on 1.1

    I want to be able to delete a row from this text file but I need to rebuild it correctly again.

    Deleting 1.1 now leads to this: (that's how far I got)

    Code:
    1.0: Choice 1 without followups
    1.2: Choice 3 with 3 followups
    1.2-2.0: 1st followup of choice3
    1.2-2.1: 2nd followup of choice3
    1.2-2.2: third followup of choice3
    1.3: Choice 4 without followups
    As you can see, choice3 follows on choice 1 and then my app crashes

    The right output would be:

    Code:
    1.0: Choice 1 without followups
    1.1: Choice 2 with 3 followups
    1.1-2.0: 1st followup of choice3
    1.1-2.1: 2nd followup of choice3
    1.1-2.2: third followup of choice3
    1.2: Choice 3 without followups
    choice3 actually becomes choice 2, choice 4 becomes choice 3,... because 1 choice got cut out...
    Kind Regards,

    Pieter

    PS: If you found someone's answer helpful, please be so kind to rate that person.
    Thanks.

  5. #5
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Ahh got ya now.

    Umm..hmm

    Well I would probably go about it by first sticking the whole thing in an array. After deleteing pull out the first to third characters in the string of every array element after the deleted one, turn it into a integer (using val function), subtract .1 from it, then rebuild the string in its place.

    will need mid$ val(or CSingle probably) and instr$ functions.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  6. #6

    Thread Starter
    Hyperactive Member Petergotchi's Avatar
    Join Date
    Jan 2002
    Location
    Dendermonde - Belgium
    Posts
    267
    The thing is allready in an array, I allready got the code to delete the choice and followups. Then I get the 2nd code, but now i need a procedure to patch the missing choice...

    Can you help me write it?

    Another problem:
    There could be choices named:
    1.11, 99.1, 84.35,...
    So the length can differ...
    Kind Regards,

    Pieter

    PS: If you found someone's answer helpful, please be so kind to rate that person.
    Thanks.

  7. #7
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Ill try to write something up for you before I leave work.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  8. #8

    Thread Starter
    Hyperactive Member Petergotchi's Avatar
    Join Date
    Jan 2002
    Location
    Dendermonde - Belgium
    Posts
    267
    Another problem I hit was this:

    When you delete a followup that also has followups then the procedure you suggested won't work, I think.

    1.0
    1.1
    1.1-2.1
    1.1-2.1-3.1
    1.1-2.1-3.2
    1.1-2.1-3.3
    1.1-2.2
    1.2

    When I want to delete the 1.1-2.1 choice, then you can't just take the first characters... Grmbl
    Kind Regards,

    Pieter

    PS: If you found someone's answer helpful, please be so kind to rate that person.
    Thanks.

  9. #9

  10. #10

    Thread Starter
    Hyperactive Member Petergotchi's Avatar
    Join Date
    Jan 2002
    Location
    Dendermonde - Belgium
    Posts
    267
    I've written a program that gives you choices.

    1.0: Title
    1.1: choice 1
    1.2: choice 2
    1.3: choice 3

    Each choice can have followups and can be added through an admin app that creates the file.

    1.0: Title
    1.1: choice 1
    1.1-2.0: Title2
    1.1-2.1: Followup of choice 1
    1.1-2.2: Followup of choice 1
    1.1-2.3: Followup of choice 1
    1.2: choice 2
    1.3: choice 3

    That means everything's variable... You can create as many choices as you want...

    So Yes, I want to be able to edit the file, it represents a choice making mechanism, and no it can't be changed because the rest is allready written. It's only that last item I explained here that's a problem.
    Kind Regards,

    Pieter

    PS: If you found someone's answer helpful, please be so kind to rate that person.
    Thanks.

  11. #11
    New Member
    Join Date
    Apr 2004
    Posts
    1
    What does the array you are storing this information in look like?

    I don't understand how you can do say..... Dim choice(4,2)..... and then change it to say..... Dim choice(4,2,5)

    Kinda hard to help without knowing these things...
    Post a sample of the code, and maybe i can help

  12. #12

    Thread Starter
    Hyperactive Member Petergotchi's Avatar
    Join Date
    Jan 2002
    Location
    Dendermonde - Belgium
    Posts
    267
    The array I'm using is 1 dimensional...

    Dim aryData() as string

    The "data.dat" file (which I written above) is read in the array...

    arydata(0) = line 1 of the file
    arydata(1) = line 2 of the file
    arydata(n) = line n of the file
    ... You get the picture

    I will post a sample of my choice deleting procedure when I get the chance. I'm at work at the moment and forgot my notebook in my car.

    Thx in advance
    Kind Regards,

    Pieter

    PS: If you found someone's answer helpful, please be so kind to rate that person.
    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width