Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Create executable with gforth

1,124 views
Skip to first unread message

ark...@gmail.com

unread,
Dec 31, 2014, 8:35:02 AM12/31/14
to
Hi!

Help me please understand how to create executables like "gforth" and "gforthmi" using gforth. As I understand I can use gforthmi with flag --application but I have no idea how I can specify what code should be executed (I mean -e option for forth).


For example, I have hello world code:

: greet ( -- ) ." Hello, World!" ;

How I can create an executable image or something like that?

Yours sincerely,
Arkadii Rost

Anton Ertl

unread,
Dec 31, 2014, 10:55:54 AM12/31/14
to
ark...@gmail.com writes:
>Hi!
>
>Help me please understand how to create executables like "gforth" and "gforthmi" using gforth.

"gforth" is a native code binary. Gforth does not have any particular
support for creating such files.

gforthmi is a shell script. You could wite the text of a shell script
using Gforth, but I guess that's not your question.

> As I understand I can use gforthmi with flag --application but I have no idea how I can specify what code should be executed (I mean -e option for forth).
>
>
>For example, I have hello world code:
>
>: greet ( -- ) ." Hello, World!" ;
>
>How I can create an executable image or something like that?

The simplest way is to make a gforth script. Create a file "hello"
that contains:

#! /usr/bin/gforth
: greet ( -- ) ." Hello, World!" ;
greet cr
bye

and then make that file executable with "chmod +x hello". Now you can
type "hello" and (if gforth is found at /usr/bin/gforth) that will run
the Forth program.

Alternatively, you can create an image. Have a file hello.fs that
contains

: greet ( -- ) ." Hello, World!" cr bye ;
' greet is 'cold

Now create an image with

gforthmi hello1 hello.fs

Now you can invoke the image with "hello1". Note that both the image
and the script need an installed Gforth to work.

- 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: http://www.forth200x.org/forth200x.html
EuroForth 2014: http://www.euroforth.org/ef14/

visua...@rocketmail.com

unread,
Dec 31, 2014, 12:51:31 PM12/31/14
to
If you are not chained to gForth, you can use VisualFORTH which is based on Win32Forth. While it is possible with Win32Forth to make turnkey programs (exe-files) easily, VisualFORTH is made to make GUIs, and VisualFORTH generates an exe-file (executable image) with one click only.

ark...@gmail.com

unread,
Dec 31, 2014, 1:13:54 PM12/31/14
to
> Alternatively, you can create an image. Have a file hello.fs that
> contains
>
> : greet ( -- ) ." Hello, World!" cr bye ;
> ' greet is 'cold
>
> Now create an image with
>
> gforthmi hello1 hello.fs

Yes, it is practically all I need. Is there a way to pass greet as a parameter during image creating? I've tried something like:
gforthmi hello1 hello.fs -e greet
but it doesn't work as I expect.

> If you are not chained to gForth, you can use VisualFORTH which is based on Win32Forth.
It's not an option for me as a linux user.

visua...@rocketmail.com

unread,
Dec 31, 2014, 1:37:36 PM12/31/14
to
On Wednesday, December 31, 2014 1:13:54 PM UTC-5, ark...@gmail.com wrote:
>
> > If you are not chained to gForth, you can use VisualFORTH which is based on Win32Forth.
> It's not an option for me as a linux user.

Sorry about that. May be someday there will be somebody writing a "One-Click-Exe" tool for a linux Forth.

There may be people in this world who are running VisualFORTH using WINE.
Exe files generated with VisualFORTH are running under linux/WINE.

empty-buffers

unread,
Dec 31, 2014, 4:53:21 PM12/31/14
to
In comp.lang.forth, visua...@rocketmail.com wrote:

> VisualFORTH is made to make GUIs

Does VisualFORTH allow access to "native" Windows' widgets? For example:
is it possible to open "print" window (with usual settings, "Print" button
etc.) from a Forth level?
--
May the Forth be with you!

humptydumpty

unread,
Dec 31, 2014, 4:59:09 PM12/31/14
to
Hi!

There is ciforth for linux: lina (google for it).

Happy New Year!
humptydumpty

visua...@rocketmail.com

unread,
Dec 31, 2014, 9:05:16 PM12/31/14
to
On Wednesday, December 31, 2014 4:53:21 PM UTC-5, empty-buffers wrote:
> In comp.lang.forth, visualforth.com wrote:
>
> > VisualFORTH is made to make GUIs
>
> Does VisualFORTH allow access to "native" Windows' widgets? For example:
> is it possible to open "print" window (with usual settings, "Print" button
> etc.) from a Forth level?
> --
> May the Forth be with you!

VisualFORTH is Forth in the first place, to make GUIs using graphic functions. To access other programs outside Forth I always use command lines using batch files.

I never heard about "native" Windows' widgets before, so I googled for it:
"The Standard Widget Toolkit (SWT) is a graphical widget toolkit for use with the Java platform. It was originally developed by Stephen Northover at IBM and is now maintained by the Eclipse Foundation in tandem with the Eclipse IDE. It is an alternative to the Abstract Window Toolkit (AWT) and Swing Java GUI toolkits provided by Sun Microsystems as part of the Java Platform, Standard Edition.

To display GUI elements, the SWT implementation accesses the native GUI libraries of the operating system using JNI (Java Native Interface) in a manner that is similar to those programs written using operating system-specific APIs"
Source: http://en.wikipedia.org/wiki/Standard_Widget_Toolkit

VisualFORTH does not have a Java Native Interface. So you are on your own then.
May be you know how to get a Java Native Interface controllable by CLI.

visua...@rocketmail.com

unread,
Dec 31, 2014, 11:17:12 PM12/31/14
to
Additional answer: There is a chance to be a pioneer!
I waited ten years for a VisualFORTH. Nothing happened. So I did it myself.
You are asking for access to "native" Windows' widgets? Don't wait!
Take the chance!
Be a pioneer!
I am sure there will be help when you start, even unexpected help!

VisualFORTH is fully documented together with Win32Forth, the download is complete with all sources and an easy to use metacompiler.

I added more than 200 changes to ForthForm, which is the Win32Forth app VisualFORTH is based on, to get VisualFORTH done as it is now.

So, don't be shy. I am sure, it can be done.
One more step into the future.

empty-buffers

unread,
Jan 1, 2015, 5:54:48 AM1/1/15
to
In comp.lang.forth, visua...@rocketmail.com wrote:

> Additional answer: There is a chance to be a pioneer!
> I waited ten years for a VisualFORTH. Nothing happened. So I did it myself.
> You are asking for access to "native" Windows' widgets?

"Native" widgets are the ones provided by OS (and his environment) - and
which are not built by the "tool" (VisualFORTH in this case).

> Don't wait!
> Take the chance!
> Be a pioneer!
> [..]
> So, don't be shy. I am sure, it can be done.
> One more step into the future.

The problem is I'm Linux user (since 1994; since about 2005 almost
exclusively), and I rather seldom use Windows. That's why I was hoping for
"something ready to use".

Mark Wills

unread,
Jan 1, 2015, 6:00:39 AM1/1/15
to
I believe VFX from MPE can do it, but it is a commercial system. It's not free. Swift Forth from Forth Inc. May also do it. Again, a commercial system. I'm sure there will be some free ones that can do it but I don't know the names of them, sorry.

empty-buffers

unread,
Jan 1, 2015, 6:40:46 AM1/1/15
to
Well, that's another problem. Not having in mind any commercial use at the
moment, I'm not that willing to pay. But I downloaded evaluation version of
SwiftForth - it won't harm to take a look at newest release.

Anton Ertl

unread,
Jan 1, 2015, 10:59:25 AM1/1/15
to
ark...@gmail.com writes:
>> Alternatively, you can create an image. Have a file hello.fs that
>> contains
>>
>> : greet ( -- ) ." Hello, World!" cr bye ;
>> ' greet is 'cold
>>
>> Now create an image with
>>
>> gforthmi hello1 hello.fs
>
>Yes, it is practically all I need. Is there a way to pass greet as a parameter during image creating?

Sure:

gforthmi hello1 hello.fs -e "' greet is 'cold"

> I've tried something like:
>gforthmi hello1 hello.fs -e greet
>but it doesn't work as I expect.

Why did you expect that that would work?

ark...@gmail.com

unread,
Jan 1, 2015, 2:39:57 PM1/1/15
to
> Sure:
>
> gforthmi hello1 hello.fs -e "' greet is 'cold"
Thank you!

> > I've tried something like:
> >gforthmi hello1 hello.fs -e greet
> >but it doesn't work as I expect.
>
> Why did you expect that that would work?
I expect that it would be passed to image as a parameter.

Albert van der Horst

unread,
Jan 4, 2015, 7:57:30 AM1/4/15
to
In article <ab46bfb9-23af-4ad9...@googlegroups.com>,
If this is a recurring situation and you're running on 32/64 bits
linux or 32 bit Windows and don't mind to have a less powerfull Forth
than gforth, you can use lina/wina.

In this case you could compile the above with

lina -c hello.frt

and have a file hello

(or on most MS systems
wina -c hello.frt
and have hello.exe).

Those files can run on other systems without the need to have
any type of runtime on those systems.

>
>Yours sincerely,
>Arkadii Rost


Groetjes Albert
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

Albert van der Horst

unread,
Jan 4, 2015, 8:14:14 AM1/4/15
to
In article <323d9923-3545-4620...@googlegroups.com>,
Passing parameters to a ciforth program is pretty straightforward:
-------------------8<----------------------->8----------------------
: hello
"HERE is your private message:" TYPE CR
1 ARG[] TYPE CR ;
-------------------8<----------------------->8----------------------
This is compiled as usual.
You can also use scripts, but that requires an installed ciforth
on the system where it must run. The above doesn't.

-------------------8<----------------------->8----------------------
#!/usr/bin/lina32 -s
"HERE is your private message:" TYPE CR
1 ARG[] TYPE CR
-------------------8<----------------------->8----------------------
If the above is put in a file lina.script with execute permission
you get:
"
albert@cherry:/tmp$ hello.script "winter is coming"
HERE is your private message:
winter is coming

"
See also http://www.forth.hcc.nl/w/Ciforth/RealPrograms
(you may have to click on the union yack for English text).

Albert van der Horst

unread,
Jan 4, 2015, 8:47:17 AM1/4/15
to
In article <slrnmaa9rp.2ff.empty.bu...@Ferrycy.localdomain>,
empty-buffers <empty.buffersYO...@gmail.NEITHER-THIS.com> wrote:
>In comp.lang.forth, visua...@rocketmail.com wrote:
>
>> Additional answer: There is a chance to be a pioneer!
>> I waited ten years for a VisualFORTH. Nothing happened. So I did it myself.
>> You are asking for access to "native" Windows' widgets?
>
>"Native" widgets are the ones provided by OS (and his environment) - and
>which are not built by the "tool" (VisualFORTH in this case).

Actually most Forths on MS-Windows can use DLL's. The only requirement is
that you have the documentation in detail (which requires that the size of
fields within structs are known by their byte count.).
Those spec's are partly in c-type include file and some Forths
do a good job interpreting those files.

If you've the documentation and perseverance, you can use all DLL's
from a simplistic Forth like wina, with only the words
LOAD-DLL DLL-ADDRESS ICALL CALL
and maybe one screen of auxiliary words.

(I was surprised to find this out. It is actually easier than using
shared object libraries -- .so -- in linux).
>
>> Don't wait!
>> Take the chance!
>> Be a pioneer!
>> [..]
>> So, don't be shy. I am sure, it can be done.
>> One more step into the future.
>
>The problem is I'm Linux user (since 1994; since about 2005 almost
>exclusively), and I rather seldom use Windows. That's why I was hoping for
>"something ready to use".

It may be much simpler than you expect.

>--
>May the Forth be with you!

0 new messages