[futurebasic] Re: [FB] Reading carriage returns

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2003 : Group Archive : Group : All Groups

From: Jay Reeve <jayreeve@...>
Date: Wed, 24 Sep 2003 14:34:55 -0500
>  >>>>>> If an edit field contains two lines of Text and the lines are
>>>>>   separated by a
>>>>>>>    CR, how should I save and read? Reading with Input# or Line 
>>>>>>>Input# will
>>>>>>>   not
>>>>>>>    read all of the original text since a CR terminates the
>>>>>>>   operation. Is Write#
>>>>>>>    and Read# the best solution? If so, should the length of the
>>>>>>>   string be saved
>>>>>>>    so it can be used with Read# ?
>>>>>>>    Thanks
>>>>>>>    Barrie
>>>>>>
>>>>>>    Barrie,
>>>>>>
>>>>>>    Personally, I would use WRITE FIELD and READ FIELD, but if your needs
>>>>>>    can guarantee you'll never have over 255 chars, then WRITE# and READ#
>>>>>>    can work.
>>>>>>
>>>>>>    If that's the route you choose, yes, I would save the length byte so
>>>>>>    you can use READ#.
>>>>>>
>>>>>>    e-e
>>>>>>    =J= a  y
>>>>>>     "
>>>>>   Thank you Jay for the advice. I'm now using READ# and WRITE# for < 255
>>>>>   characters.
>>>>>   I can probably send and retrieve a container$$ to/from disc using WRITE
>>>>>   FIELD and WRITE FIELD if the EDIT FIELD is active, but how do I save and
>>>>>   retrieve a container$$ (with CR's) when the EDIT FIELD is not 
>>>>>available? A
>>>>>   container example on the CD shows the use of PRINT# / INPUT# but I don't
>>>>>   think it will work properly with embedded CR's. WRITE# 
>>>>>container$$;lenByte
>>>>>   produces a compile error.
>>>>>   Barrie
>>>>
>>>>   Barrie,
>>>>
>>>>   For containers (or other handles), we have WRITE FIELD and READ
>>>>   FIELD. They save the length for you, too, so you don't have to worry
>>>>   about it. (Read about GET FIELD, too.)
>>>>
>>>>   I could give an example, but I'm short on time and you'll do better
>>>>   to figure it out yourself.
>>>>
>>>>   hth,
>>>>   e-e
>>>>   =J= a  y
>>>  How do I get the handle to myContainer$$ ?
>>>  Barrie
>>
>>  A container$$ essentially is a handle, with special manipulations by
>>  the runtime. I guess the easiest would be
>>
>>  ctnrH& = [@myContainer$$]
>>
>>  I doubt you even need the container var. Just take your EF handle
>>  from GET FIELD and save it.
>>
>>  e-e
>>  =J= a  y
>>
>Jay
>Many thanks, that helps a lot. Am I correct in assuming that a saved EF
>handle will remain valid, even after the field and window is closed?
>Barrie
If you're talking about the handle you get with GET FIELD, it is a 
ZTXT _copy_ of the text in the EF, not the handle used by the EF. As 
such, when you want to put it into a new EF, you just use

EDIT FIELD EFnum, &ZTXTHandle  // Note the &

where ZTXTHandle is the one you just read from disk using READ FIELD.

  e-e
  =J= a  y
   "