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

eFORTH windows - Extend graphics vocabulary for Windows

73 views
Skip to first unread message

Marc Petremann

unread,
Mar 11, 2023, 4:46:28 AM3/11/23
to
Hello,
eFORTH allows access to Windows function libraries using the word dll.
https://eforth.arduino-forth.com/article/installation_windows_extendGraphics

Marc Petremann

unread,
Mar 11, 2023, 5:15:54 AM3/11/23
to

minf...@arcor.de

unread,
Mar 11, 2023, 5:27:20 AM3/11/23
to
Do you run your eforth within a text mode console?

If yes, you have to open another window, right?

If no, which graphics-enabled terminal emulator do you use?

I'd like to see some screen shots.

none albert

unread,
Mar 11, 2023, 6:21:22 AM3/11/23
to
In article <5a675ef1-2467-4bb6...@googlegroups.com>,
Have you stopped beating your wife?
You command MS-Windows itself to open a window, and you
talk about an emulator, what??

>
>I'd like to see some screen shots.

Show you a source accepted by wina.
wina is a console Forth opened in a terminal window.
I give you my word that it opens a graphical window and sports a
dialogue.
I think DLL is a bad name for calls to the MS operating
system. I use `` CALL '' or `` CALL[ ... par# .. par# .. CALL] ''
CALL accepts parameters in the usual way.
CALL] allows the parameters to be positioned in place
using words PAR3, that fills in the third parameter.
\ ------------------------------------------------
\ A vd Horst, vrij naar FASM
\ Beer - example of tiny (one section) Win32 program

HEX
20 CONSTANT MB_ICONQUESTION
4 CONSTANT MB_YESNO
6 CONSTANT IDYES


WANT K32
"USER32.DLL" LOAD-DLL: user32
"MessageBoxA" 'user32 DLL-ADDRESS: MessageBoxA
"WINMM.DLL" LOAD-DLL: winmm
"mciSendStringA" 'winmm DLL-ADDRESS: mciSendStringA

"open cdaudio" Z CONSTANT _cmd_open
"set cdaudio door open" Z CONSTANT _cmd_eject
"close cdaudio" Z CONSTANT _cmd_close


"Do you need additional place to put the beer?" Z CONSTANT _message
"Desktop configuration" Z CONSTANT _caption

: handle-error DUP ?ERROR ;

: MAKE-PLACE-FOR-BEER
0 0 0 _cmd_open mciSendStringA .S CALL .S handle-error .S
0 0 0 _cmd_eject mciSendStringA CALL .S handle-error .S
0 0 0 _cmd_close mciSendStringA CALL .S handle-error .S
;

: beer[] \ HEX
MessageBoxA DROP \ preload
CALL[
MB_ICONQUESTION MB_YESNO OR PAR4
_caption PAR3
_message PAR2
0 PAR1
MessageBoxA CALL]
.S
IDYES = IF
MAKE-PLACE-FOR-BEER
THEN
;

\ --------------------------------

You can load the source on wina. Then beer[]
opens a window and asks a question.
The window remains open after answering the question.
After that you can go on with Forthing, and you can close
the graphical window, or not.

There are subtleties involved. This program can be made
into beer.exe, and this executable works on other
machines where wina is not installed (but it requires
winmm, of course).

Note that you only need -- besides CALL itself --
LOAD-DLL and DLL-ADDRESS .
All the other information, the commands for the cd-player,
the actual value for IDYES , the name of the multi-media
DLL etc. can be found in the Microsoft documentation.

Actually finding the documentation is two order of magnitudes
more difficult/time consuming than writing a graphical application.

Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

Marc Petremann

unread,
Mar 11, 2023, 6:30:57 AM3/11/23
to

Marc Petremann

unread,
Mar 11, 2023, 6:37:31 AM3/11/23
to
Have your a blog or web pages with tutorials, source code....?

minf...@arcor.de

unread,
Mar 11, 2023, 9:07:19 AM3/11/23
to
none albert schrieb am Samstag, 11. März 2023 um 12:21:22 UTC+1:
> In article <5a675ef1-2467-4bb6...@googlegroups.com>,
> minf...@arcor.de <minf...@arcor.de> wrote:
> >Marc Petremann schrieb am Samstag, 11. März 2023 um 10:46:28 UTC+1:
> >> Hello,
> >> eFORTH allows access to Windows function libraries using the word dll.
> >> https://eforth.arduino-forth.com/article/installation_windows_extendGraphics
> >
> >Do you run your eforth within a text mode console?
> >
> >If yes, you have to open another window, right?
> >
> >If no, which graphics-enabled terminal emulator do you use?
> Have you stopped beating your wife?

Dutch courtesy is often some somewhat peculiar ...
perhaps their niveau has adapted to their living below sea level ...

> You command MS-Windows itself to open a window, and you
> talk about an emulator, what??

Many ways lead to Rome, f.ex.
- from the Windows command line terminal, open a separate window
get its handle, and draw on its canvas
- use Sixel graphics to display bitmaps within the terminal itself
- use a terminal emulator with graphic support instead of the standard
Windows command line terminal, or a graphics console like Jupyter
noteboks can do
etc

The question remains: what is the easiest way from Forth's QUIT outer
text interpreter to do some inline graphics for 2D plotting?
I'd love to see f.ex. a sine curve
within the Forth terminal like:

> -10e +10e draw-sine \ hit return
> [sine curve appears] ok

like shown here
https://qtconsole.readthedocs.io/en/stable/index.html

> wina is a console Forth opened in a terminal window.
> I give you my word that it opens a graphical window and sports a
> dialogue.

Dialog boxes are for kids. Draw me a diagonal line in a command line terminal.
p.s. then move/resize the terminal window.

none albert

unread,
Mar 11, 2023, 9:52:24 AM3/11/23
to
In article <b4a6d6aa-1d7f-4825...@googlegroups.com>,
minf...@arcor.de <minf...@arcor.de> wrote:
>none albert schrieb am Samstag, 11. März 2023 um 12:21:22 UTC+1:
>> In article <5a675ef1-2467-4bb6...@googlegroups.com>,
>> minf...@arcor.de <minf...@arcor.de> wrote:
>> >Marc Petremann schrieb am Samstag, 11. März 2023 um 10:46:28 UTC+1:
>> >> Hello,
>> >> eFORTH allows access to Windows function libraries using the word dll.
>> >> https://eforth.arduino-forth.com/article/installation_windows_extendGraphics
>> >
>> >Do you run your eforth within a text mode console?
>> >
>> >If yes, you have to open another window, right?
>> >
>> >If no, which graphics-enabled terminal emulator do you use?
>> Have you stopped beating your wife?
>
>Dutch courtesy is often some somewhat peculiar ...
>perhaps their niveau has adapted to their living below sea level ...
>
>> You command MS-Windows itself to open a window, and you
>> talk about an emulator, what??

I misunderstood. The question was on the premise that you don't
open another window. Then you are forced to do graphics in the
window the console forth runs in and the question is natural.
Sorry.

>
>Many ways lead to Rome, f.ex.
>- from the Windows command line terminal, open a separate window
> get its handle, and draw on its canvas

Probably the way to do it.

minf...@arcor.de

unread,
Mar 11, 2023, 11:11:49 AM3/11/23
to
none albert schrieb am Samstag, 11. März 2023 um 15:52:24 UTC+1:
> In article <b4a6d6aa-1d7f-4825...@googlegroups.com>,
> minf...@arcor.de <minf...@arcor.de> wrote:
> >Many ways lead to Rome, f.ex.
> >- from the Windows command line terminal, open a separate window
> > get its handle, and draw on its canvas
> Probably the way to do it.

Not necessarily. There is f.i. the famous Mintty terminal emulator
that supports fonts, images, sixel and vector graphics:
https://mintty.github.io/

Marcel Hendrix

unread,
Mar 11, 2023, 11:45:57 AM3/11/23
to
iForth actually uses a GUI window and emulates a terminal in it.
This was done because it needs to intercept Windows
messages that are generated by application windows (like
the text editor and the graphics console). In hindsight it was
a bad design decision because it complicated useful things like
command line parameter parsing and (especially) redirection.

At the time I didn't know it was possible to install a message
pump in a terminal window (or maybe that facility didn't exist
at the time).

I think there was an iForth version that could do graphics in
the main window, but I found that inconvenient after a while
and stopped supporting it. What is more useful is to work as
usual on the console with all graphic output appearing in a
GUI window.

Sometimes one wants a commandline for the graphics
console, but it was quite an effort to make that work with
variable-sized justified fonts, color, and cut-and-paste.

-marcel

none albert

unread,
Mar 11, 2023, 3:37:26 PM3/11/23
to
In article <5b2df9de-dde3-42c2...@googlegroups.com>,
Impressive. It is a multimedia package duplicating MS Windows.

For MS-windows I have written a one person shooter games and a pipe
organ designer package, and was involved (doing the graphics) for a
simulation package. These were all in C/C++.
These highly graphical packages lean heavily on facilities
MS-Windows provide.
Doing dll calls from within Forth was a kind of relevation,
but that didn't entice me doing these projects it in Forth.

I can see that for a modest requirement (plotting a sine wave,
allowing the windows to be resized ..) mintty could be the
fastest solution.
0 new messages