Re: Functions are not Recognised correctly (FORTH)
Posted: Tue Nov 17, 2015 10:52 am
i will try to setup a example File.
Use this forum to ask for help, submit a bug report or make a suggestion.
http://www.zeusedit.com/zBB3/
Code: Select all
\ General Information:
\ Every code item has to be separated by a space. Otherwise it is part of a Function- or Variablename.
\ Functions:
: Name Functioncode ;
\ Functions starting with : and trailing space or simply a : because the space would be the delimiter.
: :Name Functioncode ;
\ Would be the same as above but now the second : is part of the Function name.
\ The first word after : and a whitespace is a Function name so a empty Function would be
: Empty-Function ;
\ Every Possible Character could be part of the Funtion name as long as the name is not separated by a space
\ Worst example for a Function name would be:
: /\][~!°?^{ ;
\ But it would be correct because there is no space between the Characters.
: correct?name ; \ not separated the whole word is taken as name despite the question mark
: incorrect name ; \ separated. And the "name" would now be recognised as code of the function "incorrect"
\ Variables:
\ Variables are similar to functions but are indicated by the word Variable.
Variable Name_of_the_Variable \ this Variable is already supported by Zeus
Variable V$name \ I personaly use V$ as name beginning only for readability
\ Same goes for Constants
Constant This-is-a-Constant
Constant C$name
\ Picking up Variables is working fine in Beta 6 as long as there are no special Charakters. So the given V$name and C$name Objects are not read. But for me this would be helpful
\ For comments there are two types used by native Forth wich are ( ) for Block Comment and \ for line comment. As always, to take effect these have to be within Spaces
: (noComment) ( Comment ) \ Comment
\ The comment issue in this case is solved as from Beta6 but the Function name is not tagged due to the special Charakters
\ Here are some Coding examples:
: Hello ." Hello World" . ; \ Already Working.
: !test 10 V$Variable ! ; \ here ! is the expression to store the value 10 into the variable. but it is also used in the function name
: @test V$Variable @ . ; \ in this example @ is on one side part of the function name on the other side with spaces it is a fetch opperator. the Single point with spaces is the print opperator
\ Here is a little Case Function
VARIABLE V$Number
: wich-number? ( n1 - ) \ Function name with Stack info comment
DUP V$Number ! \ Dupplicate the last Stack item and put one stack item in the Variable
CASE \ get the next stack item for the Case decision
0 OF ." it was " V$Number @ . ENDOF \ decide the case, fetch and print the content of the Variable
1 OF ." it was " V$Number @ . ENDOF \ ...
ENDCASE \ end the Case
;
\ Strings:
\ As said earlyer in the thread here are the different String delimiters.
," <string>"
,\" <string>"
,U" <string>"
,U\" <string>"
,Z" <string>"
,Z\" <string>"
C\" <string>"
S\" <string>"
Z" <string>"
Z\" <string>"
." <string>"
I think the best Zeus can do is identify the "string" portion, but not the different types of strings.\ As said earlier in the thread here are the different String delimiters.
," <string>"
,\" <string>"
,U" <string>"
,U\" <string>"
,Z" <string>"
,Z\" <string>"
C\" <string>"
S\" <string>"
Z" <string>"
Z\" <string>"
." <string>"
Code: Select all
00101000 CONSTANT C$Binary
Thanks for that information I will fix this in the Zeus installer.these type of Block comment is not standard Forth but Swift Forth
for a Constant declaration there has to be a Value before Constant.
Code: Select all
\ These are Constants
00101000 Constant This-is-a-Constant
00101000 Constant C$name
00101000 CONSTANT C$Binary
Code: Select all
\ These ARE NOT Constants
Constant C$name1
CONSTANT C$Binary1
Constant This-is-a-Constant1