Deutsch   English   Français   Italiano  
<vb9ap7$3pdr2$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!uucp.uio.no!fnord.no!news1.firedrake.org!nntp.terraraq.uk!nntp-feed.chiark.greenend.org.uk!ewrotcd!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Gerry Jackson <do-not-use@swldwa.uk>
Newsgroups: comp.lang.forth
Subject: Re: Using include-file
Date: Wed, 4 Sep 2024 10:54:48 +0100
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <vb9ap7$3pdr2$1@dont-email.me>
References: <vb565d$2vcqf$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 04 Sep 2024 11:54:47 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="dc1a2d19ea17c06cdedad6d49c1b6e44";
	logging-data="3979106"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/rj4tp4wkQc5K+g/rNxfqKn/Is98UlKxU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:tgk9RXE8UWnmChpXRfcHybIoQyg=
Content-Language: en-GB
In-Reply-To: <vb565d$2vcqf$1@dont-email.me>
Bytes: 2296

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