Re: Reading/Writing to array

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: benben (benhongh_at_yahoo.com.au)
Date: 11/24/04


Date: Wed, 24 Nov 2004 16:24:06 +0800

Hi! I am unable to assess your problem because you have not speculated your
problem.

In your dilema section, you gave a suspection but not a problem. What is the
code like? Give us a sample or at least a hint. What is the problem like?
What did you observe? What is the incorrect output that surprised you?

So far it all sounds pretty all right to me. The String.split method does
give empty strings when encountering consecutive delimiters, and it should
bring you to what you would have expected.

As an alternative approach to delimiter, you can store each data item with
the first few characters indicating the length of the data. when you retore
the data from the text, use a loop, first read the length, then read the
subsequent text of that length, and repeat it again. But I suspect it will
only increase your work.

ben

> Hi Everyone,
> This is probably easy.
>
> My situation: I am creating an array in my application to store client
> data. I store the data in a series of 7 items in the array and sometimes
> some of the values are blank. I just set the value to "" and it works
fine.
>
> My dilema: I take that array and write it to a text file using a
character
> as a delimiter between items. When I read that text file into my script
and
> back into an array I use the split command to dump it directly into the
> array again. I suspect the problem I am having is that the split command
> sees several delimiters in a row and does not store a value where the
empty
> items were originally.
>
> Any easy way around this? Or do I have to put filler characters into my
> array and then test for them before using the data?
>
>



Relevant Pages

  • Re: Finding the nearest match without reusing results
    ... comparing an array with a value generates an array of Trues and ... Any diff with wrong State or with used Store is implicitly zeroed out. ... Each must be larger than the absolute value of the maximum Sales ... go.....it just needs to return the closest match. ...
    (microsoft.public.excel.programming)
  • Re: read keyboard input and storing in an array?
    ... > I'm trying to store user input in an array, ... You have the beginnings of that logic already since your prompt tells the ... 201st value since the array only has room for 200 values. ... This will force you to store the int values as Integer ('Integer' ...
    (comp.lang.java.help)
  • Re: Challenge: reading ascii data
    ... to store all the data before producing any output. ... would be bad practice in terms of memory consumption to use a standard ... So I use hashes to create a two-level "sparse array", ... Well the original problem definition was: ...
    (comp.lang.fortran)
  • Re: attempting an actual game...
    ... >>> and inflexible by the absurd decision to use a bit array for square ... as then one has 8 bits in which to store a color and a few flags ... Using a 2D int (or, ... > Change direction and you may eventually complete a game. ...
    (comp.games.development.programming.misc)
  • Re: Sparse arrays
    ... >access array element, set it, sit for a bit, and read it back ... ONLY operations are STORE and RETRIEVE with no structure to the ... If you can tolerate a bit of inefficiency ... They live in sorted lists. ...
    (comp.lang.fortran)