Topic : The GFA-Basic Compendium
Author : GFA Systemtechnik GmbH
Version : GFABasic.HYP v2.98 (12/31/2023)
Subject : Documentation/Programming
Nodes : 899
Index Size : 28056
HCP-Version : 3
Compiled on : Atari
@charset : atarist
@lang :
@default : Document not found
@help : Help
@options : +g -i -s +z
@width : 75
@hostname : STRNGSRV
@hostname : CAB
@hostname : HIGHWIRE
@hostname : THING
View Ref-FileTips on porting 'C' to GFABASIC
C GFA Notes-------------------------------
&& ANDIF compare
|| ORIF compare
!=<>IF compare
===IF compare
&AND() operator
|OR() operator
%MOD() operator
!NOT operator
~NOT bitwise
^XOR bitwise
<< SHL() bitwise
>> SHR() bitwise
var++INC var
var--DEC var
a+=b a=a+b
a-=b a=a-b
a*=b a=a*b
a/=b a=a/b
a%=b a=MOD(a,b)
a&=b a=AND(a,b)
a|=b a=OR(a,b)
a^=b a=XOR(a,b)
a<<=b a=SHL(a,b)
a>>=b a=SHR(a,b)
var[x] array(x) subscript
&var *var address of
Random() XBIOS(17) 24-bit random number
These are structure referenece and must be recoded.
a->b structure dereference
a.b structure reference
Variable types:
int var word size
unsigned int card size (must use long)
char var string or byte size
int var[10] DIM var&(10)
#define var 2 replaced at compile time
Constructs like this do not work in GFA:
a=b=c=2
In 'C' this sets all variables to the value of 2.
GFA interprets this as a logic comparison and it must be recoded:
a=2
b=2 !assigned individually
c=2
The ?... : ... operatorThe ?... : ... operator is a sort of shorthand if...else... statement.
Because it is a little cryptic, it is not often used, but the basic form is as
follows:
(condition) ? expression1 : expression2;
The program evaluates condition. If it is true (not zero), then expression1 is
returned; otherwise, expression2 is returned.
For example, in the short program below, the line
bas = (foo > bar) ? foo : bar;
assigns foo to bas if foo is greater than bar; otherwise, it assigns bar to
bas.
#include <stdio.h>
int main()
{
int foo = 10;
int bar = 50;
int bas;
bas = (foo > bar) ? foo : bar;
printf("bas = %d\n\n", bas); return 0;
}
The program will print bas = 50 as a result.
Another example:
x = (x>0) ? x : -x
translates to:
IF x>0
x=x
ELSE x=-x
ENDIF which basically is the same as x=ABS(x)