• Re: Using include-file

    From minforth@21:1/5 to All on Sun Oct 27 22:32:03 2024
    It was opened in read/write mode to read or append new sections.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to Ruvim on Mon Sep 2 21:22:14 2024
    On Mon, 2 Sep 2024 20:11:25 +0000, Ruvim wrote:

    Do you know practical cases of using "include-file" in programs?

    [..]
    Using other system-specific means, this word can probably be used to
    organize inter-process communication: when a file descriptor (e.g. a
    pipe) is passed from one process to another and used as the input
    source. But why do you need to load Forth code this way?

    My SPICE simulator INCLUDE's pre-processed netlists.
    A pre-processor takes (again, INCLUDE's) the industrial-standard
    netlist and rewrites it to Forth.
    One can also write the netlist directly using Forth, but not
    every engineer is able or willing to do that.

    Debugging is easy: the original netlist runs on standard SPICE
    programs and its results can be compared directly to iSPICE's
    output when it uses the pre-processed netlist.

    The principle works for other applications too. Here some
    examples from my dfwforth/include directory:

    FORTH> grep "INCLUDE" /mnt/d/dfwforth/include/*.frt
    /assemble.frt:319: =ASM-NAME COUNT INCLUDED
    /backtrac.frt:132: ['] INCLUDE-FILE OF
    /dialogs.frt:116: R> COUNT INCLUDED
    /eplot.frt:777: SWAP @ ?DUP IF COUNT INCLUDED ( header) ENDIF /eplot.frt:796: SWAP @ ?DUP IF COUNT INCLUDED ( header) ENDIF /eplot.frt:819: SWAP @ ?DUP IF COUNT INCLUDED ( header) ENDIF /eplot.frt:838: SWAP @+ SWAP >S ?DUP IF COUNT INCLUDED ( head /eplot.frt:882: :headname @ ?DUP IF COUNT INCLUDED
    /eplot.frt:895: :dataname @ COUNT INCLUDED ;
    /graphbench.frt:261:#63 #check [IF] INCLUDE gtk3/benchmarks.frt [T /iwords1.frt:4:CR .( FORTH.LOG : edit out garbage first, then INCLUDE i /lprof.frt:357:\ Instead of INCLUDE name , IN name , S" name" INCLUDED /lprof.frt:367: S" !!!!!!!!.$$$" INCLUDED
    /lprofile.frt:198:\ Instead of INCLUDE name , IN name , S" name" INCLUD /lprofile.frt:207: S" !!!!!!!!.$$$" INCLUDED ; /playwav.frt:17:[IF] INCLUDE pwavlinu.frt
    /playwav.frt:21:[IF] INCLUDE pwavlinu.frt
    /playwav.frt:25:[IF] INCLUDE pwavewin.frt
    /runsteady.frt:620: inpbuf #11 cnt MIN S" *| INCLUDE " COMP /syssim.frt:772: EVAL" ANEW __syssim__" S" spf_model.frt" INCLUDED ; /syssim.frt:812: CR ." SPF-INCLUDE -- load spf_model.frt control/simu

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to mhx on Tue Sep 3 05:38:18 2024
    On Mon, 2 Sep 2024 21:22:14 +0000, mhx wrote:

    On Mon, 2 Sep 2024 20:11:25 +0000, Ruvim wrote:

    Do you know practical cases of using "include-file" in programs?

    [..]

    Sorry, I missed the point of your question.

    No, I never have seen any use for the FILE wordset's
    INCLUDE-FILE ( i*x fileid -- j*x ).

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to Ruvim on Tue Sep 3 06:50:18 2024
    Ruvim <ruvim.pinka@gmail.com> writes:
    Do you know practical cases of using "include-file" in programs?

    One way I am thinking about is to implement INCLUDED etc. Systems
    deal differently with relative filenames for INCLUDED, with less
    differences for OPEN-FILE. So if I want to implement a certain
    handling of relative filenames for INCLUDED in order to get rid of
    system differences, one way to do it is to do it for OPEN-FILE and
    then perform INCLUDE-FILE.

    Using other system-specific means, this word can probably be used to
    organize inter-process communication: when a file descriptor (e.g. a
    pipe) is passed from one process to another and used as the input
    source. But why do you need to load Forth code this way?

    Heinz Schnitter implemented Open Network Forth, a distributed system,
    where the parts communicated by sending Forth source code to each
    other. One could implement that by having network connections
    (telnet-style or ssh-style) between the parts, and the receiver could INCLUDE-FILE the file-id that represents his end of the connection.
    However, Open Network Forth was written around 1984, long before
    INCLUDE-FILE was standardized. Bernd Paysan uses ideas from it in his
    work, inclluding sending Forth commands between tasks, but AFAIK does
    not use INCLUDE-FILE for that.

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2024: https://euro.theforth.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to Anton Ertl on Tue Sep 3 10:23:06 2024
    In article <2024Sep3.085018@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    Ruvim <ruvim.pinka@gmail.com> writes:
    Do you know practical cases of using "include-file" in programs?

    One way I am thinking about is to implement INCLUDED etc. Systems
    deal differently with relative filenames for INCLUDED, with less
    differences for OPEN-FILE. So if I want to implement a certain
    handling of relative filenames for INCLUDED in order to get rid of
    system differences, one way to do it is to do it for OPEN-FILE and
    then perform INCLUDE-FILE.

    Using other system-specific means, this word can probably be used to >>organize inter-process communication: when a file descriptor (e.g. a
    pipe) is passed from one process to another and used as the input
    source. But why do you need to load Forth code this way?

    Heinz Schnitter implemented Open Network Forth, a distributed system,
    where the parts communicated by sending Forth source code to each
    other. One could implement that by having network connections
    (telnet-style or ssh-style) between the parts, and the receiver could >INCLUDE-FILE the file-id that represents his end of the connection.
    However, Open Network Forth was written around 1984, long before
    INCLUDE-FILE was standardized. Bernd Paysan uses ideas from it in his
    work, inclluding sending Forth commands between tasks, but AFAIK does
    not use INCLUDE-FILE for that.

    In other words. The use of INCLUDE-FILE in the wild has never been
    seen, except for a factor of INCLUDE.


    - anton

    Groetjes Albert
    --
    Temu exploits Christians: (Disclaimer, only 10 apostles)
    Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style Wall
    Art For Home, Office And Garden Decor - Perfect For Windows, Bars,
    And Gifts For Friends Family And Colleagues.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to All on Tue Sep 3 11:54:40 2024
    off-topic:

    Your SIG. Is Novabbs injecting ads, or is this a joke that
    I don't get?

    This is the third time I see it (from 2 different posters).

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gerry Jackson@21:1/5 to Gerry Jackson on Wed Sep 4 11:09:32 2024
    On 04/09/2024 10:54, Gerry Jackson wrote:
    On 02/09/2024 21:11, Ruvim wrote:
    Do you know practical cases of using "include-file" in programs?

    I can't imagine how this word could be used in standard programs.

    Only one idea: to skip BOM (byte-order mark) before include the file
    contents.

    Using other system-specific means, this word can probably be used to
    organize inter-process communication: when a file descriptor (e.g. a
    pipe) is passed from one process to another and used as the input
    source.  But why do you need to load Forth code this way?


    I've used it to redefine INCLUDED

    : included  ( ... caddr u -- ... )
       r/o open-path-file throw include-file
    ;

    where OPEN-PATH-FILE takes a string specifying a list of alternative
    relative paths to Forth source files which it tries in turn to open. It
    does this by creating an absolute directory path and calls OPEN-FILE. If
    an open succeeds it returns the file-id to be included by INCLUDE-FILE.
    If no relative path succeeds an exception is thrown.

    I've used it to test a program on several different Forth systems, each
    of which has its own way of handling relative directory paths but they
    all work with an absolute path.


    I've just seen that Anton has suggested this as a possible use of OPEN-FILE

    --
    Gerry

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gerry Jackson@21:1/5 to Ruvim on Wed Sep 4 10:54:48 2024
    On 02/09/2024 21:11, Ruvim wrote:
    Do you know practical cases of using "include-file" in programs?

    I can't imagine how this word could be used in standard programs.

    Only one idea: to skip BOM (byte-order mark) before include the file contents.

    Using other system-specific means, this word can probably be used to
    organize inter-process communication: when a file descriptor (e.g. a
    pipe) is passed from one process to another and used as the input
    source.  But why do you need to load Forth code this way?


    I've used it to redefine INCLUDED

    : included ( ... caddr u -- ... )
    r/o open-path-file throw include-file
    ;

    where OPEN-PATH-FILE takes a string specifying a list of alternative
    relative paths to Forth source files which it tries in turn to open. It
    does this by creating an absolute directory path and calls OPEN-FILE. If
    an open succeeds it returns the file-id to be included by INCLUDE-FILE.
    If no relative path succeeds an exception is thrown.

    I've used it to test a program on several different Forth systems, each
    of which has its own way of handling relative directory paths but they
    all work with an absolute path.

    --
    Gerry

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to Ruvim on Thu Oct 24 06:32:33 2024
    Ruvim <ruvim.pinka@gmail.com> writes:
    Also, `REQUIRED` does not load a file that was loaded by `INCLUDED`. >`INCLUDE-FILE` is free of that too.

    Yes, but why would anyone use REQUIRED or REQUIRE on a file that he
    intends to include even if it has been INCLUDED before?

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2024: https://euro.theforth.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to Anton Ertl on Thu Oct 24 11:30:57 2024
    In article <2024Oct24.083233@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    Ruvim <ruvim.pinka@gmail.com> writes:
    Also, `REQUIRED` does not load a file that was loaded by `INCLUDED`. >>`INCLUDE-FILE` is free of that too.

    Yes, but why would anyone use REQUIRED or REQUIRE on a file that he
    intends to include even if it has been INCLUDED before?

    Making use of the idempotent behaviour of REQUIRE ?


    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html >comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2024: https://euro.theforth.net
    --
    Temu exploits Christians: (Disclaimer, only 10 apostles)
    Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style Wall
    Art For Home, Office And Garden Decor - Perfect For Windows, Bars,
    And Gifts For Friends Family And Colleagues.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to Ruvim on Thu Oct 24 12:44:41 2024
    On Mon, 2 Sep 2024 20:11:25 +0000, Ruvim wrote:
    Do you know practical cases of using "include-file" in programs?

    I remember a script for reading csv data files with INCLUDE-FILE.
    The interpreter (parser) was slightly modified for this.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to All on Sat Nov 9 12:06:19 2024
    On Sat, 9 Nov 2024 8:29:44 +0000, rt wrote:

    Hi Marcel, the Mac Cocoa interface for i4 uses INCLUDE-FILE
    to deal with code pasted in the OS clipboard. BTW same for
    VFX and VFX64. I needed a portable/standard word, 'et voila'.

    Hi Roelf: not enough information. Isn't the file-id for the clipboard
    acquired in a non-standard way then?

    iForth's console already accepts multi-line text pasted in its
    window. In SwiftForth the pasted text seems to have a fixed (small)
    length. I don't receive VFX updates anymore (I probably said something offensive), so can't try.

    There could be a few issues with a portable solution :--)

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stephen Pelc@21:1/5 to All on Sat Nov 9 18:13:29 2024
    On 9 Nov 2024 at 13:06:19 CET, "mhx" <mhx> wrote:

    I don't receive VFX updates anymore (I probably said something
    offensive), so can't try.

    Now that all products are freely downloadable for non-commercial use,
    all you need to do is to download the latest versions from:
    https://vfxforth.com/downloads/VfxCommunity/

    Stephen
    --
    Stephen Pelc, stephen@vfxforth.com
    MicroProcessor Engineering, Ltd. - More Real, Less Time
    133 Hill Lane, Southampton SO15 5AF, England
    tel: +44 (0)78 0390 3612, +34 649 662 974
    http://www.mpeforth.com MPE website http://www.vfxforth.com/downloads/VfxCommunity/ downloads

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From rt@21:1/5 to All on Sun Nov 10 13:47:17 2024
    <quote>
    There could be a few issues with a portable solution :--)
    </quote>

    :-)

    The Cocoa interface runs in CarbonMacForth(2008), iForth(2009), SwiftForth(2010) and VFX(2012).
    Kind of recall, the Cocoa, not UNIX/Darwin, clipboard interface was
    implemented in 2010, 14 years ago! At the time not seen any remarks
    about the standard INCLUDE-FILE.
    And it still works...

    --

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From rt@21:1/5 to All on Sat Nov 9 08:29:44 2024
    Hi Marcel, the Mac Cocoa interface for i4 uses INCLUDE-FILE to deal with
    code pasted in the OS clipboard. BTW same for VFX and VFX64. I needed a portable/standard word, 'et voila'.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)