Loading...
 
Skip to main content
Emforth/Emserver and files.

EMfiles

When EMforth is a client to EMserver file access becomes very easy.

Writing files


The output text from forth interpreter can be redirected to a file in two ways.

If you want to capture text and see it on the display as well you use the word - CAPTURE.
If you want to send it to a file and not see it you use the word STDOUT.
The main reason to use the later is speed when you have a lot of text.

If you say..
CAPTURE FILENAME
do something to output text.
and type CAPTURE again....

The first CAPTURE will create and open a file. The filename is optional for all these words - if omitted you will be ask for one.
The second CAPTURE will close the file. I could use a different word set (separate close) but I haven't.

STDIO works the same way.

To dump memory to a binary file..
STRT LEN >FILE FILENAME.

Ie the start address the length >FILE and an optional name.
This is the same format as DUMP except for the filename.

Writing files from a compiled word is also quite simple but I haven't finished writing all the support words.

Reading files


The main use for reading files is to compile source code.
You just say..
SOURCE FILENAME
You can also do nested includes with.
INCLUDE FILENAME

The difference between SOURCE and INCLUDE is the former also allocates memory to compile into.

Directory layout

Forthdirectories
I arrange my directories as shown in the image above.
My applications sit in directories at the same level as the includes.

To do an include from the main source uses a line like this...
INCLUDE ..\include\IO.FTH
For each application I have a shortcut to emserver with the working directory set to my working directory.

Include files which aren't shared between applications sit in the working directory.
These can be included like this..
INCLUDE H256.DEF
I also have a simple conditional statement which can be used to only include when there is a "true" flag on the stack - for example...
PCBTYPE H256 = IFDO INCLUDE H256.DEF
This would include the file if PCBTYPE equals H256

eddie


Created by eddie. Last Modification: Sunday 19 of May, 2024 17:52:03 AEST by admin2.

Main Index

Switch Theme

Switch Theme

Shoutbox

eddie, 18:52 AEST, Wed 11 of Sep, 2024: Most pages should be working again.
System Administrator, 08:03 AEST, Sat 10 of Aug, 2024: Lots of images are still broken. I'm working on it. Maybe 1/2 way through.
admin2, 14:05 AEST, Mon 05 of Aug, 2024: running tiki 27
admin2, 16:01 AEST, Sun 09 of Jun, 2024: Wiki running tikiwiki version 27alpha on a raspberry pi-3. About 1/2 the images are missing and most thumbnails not working. Slow manual rebuild. About %20 done.
eddie, 20:23 AEST, Sun 19 of May, 2024: Images moved from wiki_up to file galleries and wiki pages fixed.

Last-Visited Pages

Online Users

23 online users
  • eddie