forth

Changing the focus back to the console window

对着背影说爱祢 提交于 2019-12-23 15:38:33
问题 My knowledge of Windows programming is close to zero. But now I have made a Forth program running from the console in Windows which opening a primitive window for graphics. The problem is that I want to control the program by pressing keys, but when the program starts there is no focus on the console window, just on the graphic window. How do I change back focus? I guess I have to use some WINAPI, but which? 来源: https://stackoverflow.com/questions/41272078/changing-the-focus-back-to-the

Does GNU FORTH have an editor?

♀尐吖头ヾ 提交于 2019-12-11 04:15:53
问题 Chapter 3 of Starting FORTH says, Now that you've made a block "current", you can list it by simply typing the word L . Unlike LIST , L does not want to be proceeded by a block number; instead it lists the current block. When I run 180 LIST , I get Screen 180 not modified 0 ... 15 ok But when I run L , I get an error :30: Undefined word >>>L<<< Backtrace: $7F0876E99A68 throw $7F0876EAFDE0 no.extensions $7F0876E99D28 interpreter-notfound1 What am I doing wrong? 回答1: Yes, gForth supports an

Load from the terminal input buffer to parameter stack

走远了吗. 提交于 2019-12-11 03:19:37
问题 Why does this code not work? TIB 10 ACCEPT TIB SP@ 1 cells - 10 cmove In that code I tried to enter a string and store it in the terminal input buffer and later store it on the parameter stack. But with .S I see that does not work. 回答1: The parameter stack grows towards low memory The main problem with the sample code is that the parameter stack grows towards low memory. So the starting point for the destination of the copy should be at a higher memory address (inside the existing/defined

How do I compare two strings in Forth?

时间秒杀一切 提交于 2019-12-10 21:01:05
问题 And can I do it in an if statement or should I make a helper boolean variable? Here's the code I have so far. By the way, IOX@ is to get input from the user. : var compile: VARIABLE complile: ; : lock compile: var realPass$ compile: realPass$ "password" ! compile: ." Enter Password: " compile: var pass$ compile: IOX@ pass$ ! compile: var match compile: realPass$=pass$ match ! Unknown token: realPass$=pass$ 回答1: The ANS FORTH word to compare strings is COMPARE (c-addr_1 u_1 c-addr_2 u_2 -- n).

How to enter numbers in Forth

拟墨画扇 提交于 2019-12-08 19:18:12
问题 Is there something like input in Basic or scanf("%d") in C in Forth? Probably it will be something like this: 200 buffer: buf : input ( -- n ) buf 200 accept some-magic-filter buf swap evaluate ; The problem in the above code, is how to define a filter that will pass only numbers, but not any words, definitions, etc? 回答1: The standard specifies only a low level >NUMBER word to interpret integer numbers. OTOH using EVALUATE to convert strings into numbers is a quick and dirty way. Either use

How do I read raw code from a website in Gforth?

情到浓时终转凉″ 提交于 2019-12-08 00:21:32
问题 I would like a word like read-site ( add n buff max -- n flag ) where 'add n' is the site name buffer, 'buff max' is the buffer to which the ASCII text should be read to, 'n' is the number of bytes that was read and flag is true if operation succeeded. Is this possible in Gforth in Linux, Android or Windows? 回答1: Just a list of approaches The most easy proper way should be to use an HTTP-client library (or binding) in Forth (if any). It seems that some kind of such library exists in the

Compiling Gforth without Gforth?

。_饼干妹妹 提交于 2019-12-07 11:59:07
问题 When I try to compile Gforth 0.7.0, I get the following error: $ ./configure $ make #compiling… Undefined symbols: "_main", referenced from: start in crt1.10.6.o ld: symbol(s) not found collect2: ld returned 1 exit status make[3]: *** [gforth-ll] Error 1 ./preforth -p ".:~+:." -e 's" mach16b.fs"' ./kernel/main.fs -e "save-cross kernl16b.fi- /usr/local/bin/gforth-0.7.0 bye" You need to configure with a gforth in $PATH to build this part make[3]: *** [kernl16b.fi-] Error 1 make[2]: *** [gforth

Implementing function calls for 8051

不问归期 提交于 2019-12-07 10:10:51
问题 Say you have an 8051 microcontroller with no external RAM. Internal RAM is 128 bytes, and you have around 80 bytes available. And you want to write a compiler for a stack language. Say you want to compile an RPN expression 2 3 + . 8051 has native push and pop instructions, so you can write push #2 push #3 Then you can implement + as: pop A ; pop 2 into register A pop B ; pop 3 into register B add A, B ; A = A + B push A ; push the result on the stack Simple, right? But in this case + is

Gforth conditional expression with variables - only partly correct

这一生的挚爱 提交于 2019-12-07 07:35:29
Simple expression: variable x ok 4 x ! ok 3 x < . -1 ok 3 x > . 0 ok This seems normal and correct, however: variable x ok 3 x ! ok x 4 < . 0 ok x 4 > . -1 ok The second block of code is wrong. What is evaluating wrongly? What is the problem here? variable x makes a new variable, but x returns the address, not the value. You need something like this: variable x 3 x ! ok x @ 4 < . x @ 4 > . 来源: https://stackoverflow.com/questions/49040227/gforth-conditional-expression-with-variables-only-partly-correct

How do I read raw code from a website in Gforth?

谁都会走 提交于 2019-12-06 07:29:40
I would like a word like read-site ( add n buff max -- n flag ) where 'add n' is the site name buffer, 'buff max' is the buffer to which the ASCII text should be read to, 'n' is the number of bytes that was read and flag is true if operation succeeded. Is this possible in Gforth in Linux, Android or Windows? ruvim Just a list of approaches The most easy proper way should be to use an HTTP-client library (or binding) in Forth (if any). It seems that some kind of such library exists in the Gforth repository — see netlib/httpclient.fs . Obviously it doesn't work with HTTPS. The next way is to use