1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-30 23:50:04 +00:00
C02/work/example.c02
2018-08-11 00:18:23 -04:00

67 lines
2.3 KiB
Plaintext

/* C02 Syntax Examples */
/* Constants */
#define TRUE $FF //Constants
#define FALSE 0
#define CR 32
enum {BLACK, WHITE, RED, CYAN, PURPLE, GREEN, BLUE, YELLOW};
/* Structures */
struct record {char name[8]; char index;}; //Struct Definition
struct record rec; //Struct Declaration
/* Declarations */
char c,e,f,g,h,k,n,p,q,v; //Variables
char i,j; //Counter Variables
char fp; //File Pointer
char line,row,col,tmp; //More Variables
const char debug = #TRUE; //Variable initialized to constant
const char flag = %01010101; //Variable initialized to literal
char hmove, s80vid; //Strobe Registers
char b[7],d[7],r[7]; //8 byte Arrays
const char s = "string"; //Const String
char t[128]; //String Array
const char l = {1,2,3}; //Const List
const char m = {"one",1}; //Mixed List
char isdgt(); //Forward declaration of function
/* Assignments */
hmove; s80vid; //Implicit Assignments
x = 0; y = a; a = 1; //Register Assignments
b = c + d - e & f | g ^ h; //Assignment and Expression
d[j] = r[i] + s[x] + t[y]; //Array Indexing
a<< ;b[i]>>; x++; y--; //Post-Operations
/* Function Calls */
i = abs(n); j = min(b,c); k = max(d,e); plot(h,v,c);
n = mult(div(m+n,d), e) - t;
puts("string"); putc(#CR); fputs(fp, &line);
c = getc(); i = strchr(c, &s); row,col = scnpos();
push d,r; mult(); pop p; //Pass via Stack
iprint(); inline "Hello World"; //Pass Inline String
irect(); inline 10,10,100,100; //Pass Inline Parameters
/* Control Structures */
if (c = 27) goto end;
if (n) q = div(n,d); else puts("Division by 0!");
if (!fp) putln("File not opened");
i = 0; while (c < 10) { prbyte(i); i++; }
while() { c=rdkey(); if (c=0) continue; putchr(c); if (c==13) break; }
do c = rdkey(); while (c=0);
do {c = getchr(); putchr(c);} while (c<>13);
for (c='A'; c<='Z'; c++) putc(c);
for (i=strlen(s)-1;i:+;i--) putc(s[i]);
for (i=0;c>0;i++) { c=getc(); t[i]=c; }
select (getc()) {
case $0D: putln("The Enter key");
case 'A','a': putln("The letter A");
default: putln("some other key");
}
end: //Label
/* Function Declaration */
char isdgt(tmp) {
if (tmp >= '0') if (tmp <= '9') return #TRUE;
return #FALSE;
}