[futurebasic] Re: [FB] Strings > 255 characters?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 1998 : Group Archive : Group : All Groups

From: tedd@...
Date: Wed, 28 Oct 1998 13:31:10 -0500
-snip-
>
>This may not qualify as a prablem--maybe just my own ignorance. Or maybe
>I missed something earlier in this thread. But it looks to me as if you
>have only a 180-character string of 2-byte characters. If these are
>really _supposed_ to be 2-byte characters, then don't you defeat that
>with b$ = CHR$(b)? According to the manual, the CHR$ function only works
>with chars 0-255.

You are correct as to the 0-255 thing. However, I don't see your
180-character comment. I was asking for _size of memory to be 2*360 (or
720). I use 2 bytes to record each ASCII value. Now, why don't I use just
one byte. You got me. I tried it and found difficulty. However, I did get a
single byte list of raw data using HEX data. Granted, this is a topic that
I don't understand thoroughly.

---
>What you really have is an integer array. It might be easier this way:
>  gNewH& = FN NEWHANDLE _clear(_size)
>  XREF@ gNewH(180)

-snip-

I don't want to use an array and I don't want to use XREF (personal
preference). I just want to have a block of memory that contains a string
of ASCII characters. I just received Mars' code regarding long strings.
I'll look at how he accomplishes the same task and it may enlighten me.

---
>If the goal was actually to store 360 characters, I think that would go
>like this:
>
>  gNewH& = FN NEWHANDLE _clear(_size)
>  prt& = [gNewH&]               'get the pointer from the handle
>  POKE WORD([prt&]), a          'store "a" as the length of the string
>  FOR i = 2 TO a
>     POKE ptr& + i, b           'store "b" as the ASCII value for each
>  NEXT                          'character of the string

Not accordingly to what I believe to be true. You first get memory for a
handle, as found in gNewH& = FN NEWHANDLE _clear(_size). Then you get the
pointer from the handle by dereferencing the handle via prt& = [gNewH&].
Once you have the pointer (THE place in memory), you can POKE and PEEKS
things in memory. However, if you then dereference the pointer, I'm not
sure what you get. What would you be after? A handle is simply a pointer to
as pointer. When you deference the handle, you get the pointer. If you
deference that then where are you?

---
>To read the string (character by character--although I don't understand
>why you would do this), you could use:
>
>  prt& = [gNewH&]               'get the pointer from the handle
>  a = PEEK WORD(ptr&)           'get the length of the string
>  FOR i = 2 to a                'move through the memory block
>     b = PEEK (prt& + i)        'get the ASCII value
>     b$ = CHR$(b)               'convert to character
>  NEXT

First, I could use it in several things (i.e., EDIT FIELD, another memory
list, etc.). The point was to get it to a string a character at a time.

Second, with using PEEK instead of PEEK WORD, you would be stripping of
characters one at a time (which is what I wanted to do), but I found that
to be problematic. That is one of the reasons that I posted this code
asking for comment.

As it is now, I am still wondering as to how one stores ASCII characters in
memory efficiently. I know that the way I did it _does work_, but I have
this strange feeling that I could do it more efficiently.

tedd

___________________________________________________________________
<mailto:tedd@...>	               http://sperling.com/