Re: RfD - 2VALUE



Alex McDonald wrote:

GerryJ wrote:
RfD - 2VALUE


==snipped==


The syntax is:
s" some string" 2VALUE stringref
to define <stringref> as a cell pair holding (caddr u) for the string
or
123. 2VALUE ddata
to define <ddata> as a double value initialized to <123.>.

To access the value of stringref and ddata:
stringref TYPE <cr> some string ok
ddata D. <cr> 123 ok

The string won't work; for systems without the FILE wordset;

<quote>
6.1.2165 S"
s-quote CORE

Interpretation: Interpretation semantics for this word are
undefined.
</quote>

and for systems with the FILE wordset

<quote>
11.6.1.2165 S"
s-quote FILE

Extend the semantics of 6.1.2165 S" to be:

Interpretation: ( "ccc<quote>" -- c-addr u )

Parse ccc delimited by " (double quote). Store the resulting string
c-addr u at a temporary location. The maximum length of the temporary
buffer is implementation-dependent but shall be no less than 80
characters. Subsequent uses of S" may overwrite the temporary buffer.
At least one such buffer shall be provided.
</quote>

Either it's ambiguous or you're in danger of addressing a buffer that
will be overwritten.


To change stringref and ddata uses TO:
s" another string" to stringref


Yes I realised that when I did the test case at the end, I suppose I
should have gone back to correct the syntax example. The syntax example
has the correct syntax but won't work for the reasons you describe.

Is there any logical reason for S" being a compile only word in the
core wordset which is then relaxed for the file-access wordset. I'd
have thought the extended behaviour was useful in the core as well.

Gerry

.



Relevant Pages

  • Re: inconsistent behavior of >FLOAT
    ... If the string represents a valid floating-point number in the syntax ... if the string does not match the syntax given then false ... ">FLOAT enables programs to read floating-point data in legible ASCII format. ...
    (comp.lang.forth)
  • Re: Just a bit of silliness
    ... Is that the syntax and grammar resemble the stammer ... Can't guess how to copy a string. ... Is the very last} "close curly bracket" ... format strings. ...
    (comp.lang.c)
  • Re: FTS Weighted Values Implementation Problem
    ... You have to convert your numeric value to string with ToStringfunction. ... a number into a textbox which assigns the weight value for each ... I don't want the user to have to work with decimals directly, ... I adjusted my SELECT statement using the syntax you provided for the ...
    (microsoft.public.sqlserver.fulltext)
  • SetText Method Confusion
    ... what is the correct syntax for the SetText Method? ... and neither will complile when I use them in my macro. ... before pasting the changed string to the new document. ... into the clipboard, from the clipboard into a DataObject, ...
    (microsoft.public.word.vba.beginners)
  • Re: String() declaration?
    ... And it becomes a Complete party of HUHS ?? ... the most the classic syntax followed by the "New" C style syntax probably ... Dim temp() as String ...
    (microsoft.public.dotnet.languages.vb)