Unable to load my code -- what am I doing wrong?

If you have any questions, remarks, ... if you need help... its here...

Unable to load my code -- what am I doing wrong?

Postby bobgillies » 05 Feb 2017 22:32

I've typed my code in Windows Notepad and tried to load it into oforth,
using the RUN command in the Search Programs and files search box in the Start Menu:
C:\oforth\oforth.exe --i --P"c:\oforth\matrix.of load"

But kept getting this message at the oforth command line:
[stdin:1:40] ExRuntime : Can't evaluate <C:\oforth\matrix.of>

So I copied the "helloworld.of" script to the same subdirectory that oforth.exe is in, and tried to RUN with this:
C:\oforth\oforth.exe --i --P"c:\oforth\helloworld.of load"

And I still get this error:
[stdin:1:40] ExRuntime : Can't evaluate <c:\oforth\helloworld.of>

What am I doing wrong?
bobgillies
 
Posts: 60
Joined: 24 Jan 2017 06:26

Re: Unable to load my code -- what am I doing wrong?

Postby Franck » 05 Feb 2017 23:12

#load takes a string and loads the file which name is this string.
But your c:\oforth\matrix.of is not between "", so it is not a string and oforth tries to interpret it.

Code: Select all
oforth matrix.of

will load matrix.of and returns. I don't think that is what you want.

Code: Select all
oforth --P"5 Matrix id .s" matrix.of

will load matrix.of, then runs the command and returns.

If you just want to load matrix.of and go into the interpreter, you can try :
Code: Select all
oforth --i --P"\"matrix.of\" load"



But the best way is to create a package and load it an startup using :
Code: Select all
oforth --i --P"import: matrix"


You can find how to create a package "matrix" into the documentation.
Or you can see an example into the packs directory.

Franck
Franck
 
Posts: 159
Joined: 29 Oct 2014 19:01

Re: Unable to load my code -- what am I doing wrong?

Postby bobgillies » 06 Feb 2017 21:21

I'll try that but here's what I noticed in my findings:
Part of problems while in oforth's Read Eval Print Loop was in the string I passed to load an .OF file:
This worked: "\matrix.of\ " load
This did not: "\matrix.of\" load

So, I caught my mistake. That's the good news.

The not so good news is probably my choice of editor (Windows NotePad, for now).

I think my editor is leaving some hidden control codes in the text file. I'll follow up with what I find out.

In the mean time, what text editor or IDE would you suggest or what text encoding (ANSI, UTF-8, Unicode, etc).

Bob
bobgillies
 
Posts: 60
Joined: 24 Jan 2017 06:26

Re: Unable to load my code -- what am I doing wrong?

Postby bobgillies » 06 Feb 2017 21:41

Some further digging in the interwebs came up with this:

"Windows uses CRLF (\r\n, 0D 0A) line endings while Unix just uses LF (\n, 0A)".

So I went and copied the helloworld.of file in the \oforth\examples\ folder and pasted it's duplicate in the \oforth\ folder. Then I opened the duplicate and replaced the helloworld definitions with the matrix definitions and saved it. Renamed the duplicate's filename to testmatrix.

It does load properly.

When I did a cut and past of the code into a Windows NotePad .txt document also name textmatrix, it would not load and I get this error:

[stdin:1:23] ExRuntime : Can't open source file < estmatrix.of >

The filename is missing the "t" caracter and replaced with a bunch of leading blanks. That's odd, don't you think? Now what would oforth's REPL expect for an End Of Line character or even End Of File character?


bob
Last edited by bobgillies on 06 Feb 2017 22:08, edited 1 time in total.
bobgillies
 
Posts: 60
Joined: 24 Jan 2017 06:26

Re: Unable to load my code -- what am I doing wrong?

Postby Franck » 06 Feb 2017 21:48

Using \" should be only used when you pass the file on the command line, because the --P option already uses " and " to define the string to execute.

So you have to write :
oforth --P" \"matrix.of\" load" --i

If you don't use \ the command line will consider that this is the end of the command you want to execute.

But, if you are already into the REPL loop, you can just type :
"matrix.of" load.

If you write :
"\matrix.of\" load
you are creating an unterminated string with a " after the f.

If you write :
"\matrix.of\ " load
\m is m and \ is a space, so it is as if you have typed
"matrix.of " load
so it works.

Currently, I use vim, but I'am trying also HolonS. If you have already used Smalltalk, you will like HolonS :)

But I don't think that notepad will add control codes. If you have an example of what is wrong with notepad, I'am interested.

Franck
Franck
 
Posts: 159
Joined: 29 Oct 2014 19:01

Re: Unable to load my code -- what am I doing wrong?

Postby Franck » 06 Feb 2017 21:50

That is because \t is not t but is a TAB, I think.

Don't use \ when into the REPL, use it just when you need a " into the --P string.

Unless you want to have special characters into a string, of course. For instance :
"abcd\tef\"gh" .s

Franck
Franck
 
Posts: 159
Joined: 29 Oct 2014 19:01

Re: Unable to load my code -- what am I doing wrong?

Postby bobgillies » 06 Feb 2017 22:20

It does indeed loads properly as you stated. I got it now. Thank you again, sir.

Bob
bobgillies
 
Posts: 60
Joined: 24 Jan 2017 06:26


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest