EXAMPLES
This page contains some examples of programming on SCCOL to help you better understand how to use it.
▼24 BOTTLES
SET 0 24;
PROC VERSE;
SAY %^0 bottles of SCP-207-1 on the wall;
SAY %^0 bottles of SCP-207-1.;
SAY Take one down, pass it around;
SET 0 (%^0 $- 1);
IF (%^0$>0) SAY %^0 bottles of SCP-207-1 on the wall.;
IF (%^0$>0) CALL VERSE;
IF (%^0$=0) SAY [REDACTED];
IF (%^0$=0) FREE 0;
IF (%^0$=0) FREE VERSE;
END;
CALL VERSE;
▼BACKGROUND RANDOMIZER
CLR;
SAY The program will set the background color to a random color.;
SAY Press any key. Press ESC to exit.;
PROC MAIN;
SET 1 (%^R$*1000);
INT 1;
BG #%^1;
KEY 0;
IF (%^0$=27) BG BLACK;
IF (%^0$=27) CLR;
IF (%^0$!=27) CALL MAIN;
IF (%^0$=27) CALL FINISH;
END;
PROC FINISH;
FREE 0 1;
FREE MAIN;
FREE FINISH;
END;
CALL MAIN;
▼HELLO WORLD
SAY Hello, World!;
▼HELLO WORLD (ADVANCED)
PROC MAIN;
SET 0 World;
SAY %$YHello, %^0!;
SET 0 you;
SAY %$LPleased to see %^0 again!;
FREE 0;
FREE MAIN;
MEM;
END;
CALL MAIN;
▼PI APPROXIMATION
SET 0 20000; // ITERATIONS;
SET 1 0; // PI;
SET 2 0; // I;
PROC CALC;
SET 3 (%^2 $* 2); // I*2;
SET 4 (%^3 $+ 1); // I*2+1;
SET 5 (4 $/ %^4); // 4 / (I*2+1);
IF ((%^2$%2)$=0) SET 1 (%^1 $+ %^5);
IF ((%^2$%2)$!=0) SET 1 (%^1 $- %^5);
WAIT 1;
IF (%^2$<%^0) SET 2 (%^2 $+ 1);
IF (%^2$<%^0) CALL CALC;
IF ((%^2$%16)$=1) CLR;
IF ((%^2$%16)$=1) SAY %^1;
END;
CALL CALC;