| NedoPC Project
| NedoPC Forum
| NedoPC Group
|
RW1 & C
RW1 programming language is very simple
(see http://rwar.net).
Syntax is similar to C-language. I can offer two programs for
show differences between C and RW1:
// hello.c
#include <stdio.h>
main()
{
printf("Hello, World");
}
// hello.rw1
robot "Hello"
author "A.Shabarshin"
main()
{
say "Hello, World"
}
So, RW1 program is "robot" with "author" and main function. At present I
develop HELP in English. There is old documentation in English
(see http://rwar.net).
Similarity C and RW1: - function main() -
structure if(){...} else{...} - structure
for(;;){...} with break and continue -
structure while(){...} with break and continue
- structure do{...}while() with break and
continue - command goto Label - command
return Expr at end of functions (only v2.1 and above)
RW1 don't have:
- multidimensional arrays - only onedimentional
- variables have size only 16-bit signed (-32768...+32767)
- any struct and union, only variables and arrays
- structure switch(){case...} and
instead
switch(var) { case 0: ok=1; break; case
2: ok=2; break; case 3: ok=10; break; }
we will
write
def labs[4]={lab0,0,lab2,lab3} goto labs[var]
lab0: ok=1; goto end lab2: ok=2; goto end lab3: ok=10;
goto end end:
- not support functions that may be used
inside expressions (largest minus), but RW1 have "procedures" (in
pascal terms) or in other words - functions that may be used inside
program body or functions body, not in expressions. And you may use
macros inside expressions. See RW1_STD.RWI include file:
@if(3)=((@1)?(@2):(@3))
@max(2)=(((@1)>(@2))?(@1):(@2))
@min(2)=(((@1)<(@2))?(@1):(@2))
@abs(1)=(((@1)<0)?(-(@1)):(@1)) @sqr(1)=((@1)*(@1))
@mod(2)=((@1)%(@2)) @and(2)=((@1)&&(@2))
@or(2)=((@1)||(@2)) @not(1)=(!(@1)) @neg(1)=(-(@1))
If you want use @max macro definition than
aa=10;bb=20;cc=@max(aa,bb)
So result will be equal 20
^ Go Up
|