add: for sample, fix bugs, and make test harness
This commit is contained in:
27
samples/fib.rpg
Normal file
27
samples/fib.rpg
Normal file
@@ -0,0 +1,27 @@
|
||||
**FREE
|
||||
Ctl-Opt Main(Perform_Fibonacci_Sequence);
|
||||
|
||||
Dcl-Proc Perform_Fibonacci_Sequence;
|
||||
|
||||
Dcl-s i Uns(10);
|
||||
Dcl-s fib Uns(10) Dim(10);
|
||||
|
||||
// Display a title
|
||||
Dsply ('Fibonacci Sequence:');
|
||||
|
||||
// Initialize the first two elements of the array
|
||||
fib(1) = 0; // The sequence usually starts with 0 and 1
|
||||
fib(2) = 1;
|
||||
|
||||
// Loop to calculate the rest of the sequence
|
||||
For i = 3 to %Elem(fib);
|
||||
// Each number is the sum of the two preceding ones
|
||||
fib(i) = fib(i-1) + fib(i-2);
|
||||
Endfor;
|
||||
|
||||
// Loop to display the sequence numbers
|
||||
For i = 1 to %Elem(fib);
|
||||
Dsply (' ' + %Char(fib(i)));
|
||||
Endfor;
|
||||
|
||||
End-Proc Perform_Fibonacci_Sequence;
|
||||
11
samples/fib.rpg.golden
Normal file
11
samples/fib.rpg.golden
Normal file
@@ -0,0 +1,11 @@
|
||||
DSPLY Fibonacci Sequence:
|
||||
DSPLY 0
|
||||
DSPLY 1
|
||||
DSPLY 1
|
||||
DSPLY 2
|
||||
DSPLY 3
|
||||
DSPLY 5
|
||||
DSPLY 8
|
||||
DSPLY 13
|
||||
DSPLY 21
|
||||
DSPLY 34
|
||||
13
samples/for.rpg
Normal file
13
samples/for.rpg
Normal file
@@ -0,0 +1,13 @@
|
||||
**FREE
|
||||
Ctl-Opt Main(For);
|
||||
|
||||
Dcl-Proc For;
|
||||
dcl-s num int(10);
|
||||
|
||||
for num = 1 to 3;
|
||||
dsply ('i = ' + %char(num));
|
||||
endfor;
|
||||
for num = 5 downto 1 by 1;
|
||||
dsply ('i = ' + %char(num));
|
||||
endfor;
|
||||
End-Proc For;
|
||||
8
samples/for.rpg.golden
Normal file
8
samples/for.rpg.golden
Normal file
@@ -0,0 +1,8 @@
|
||||
DSPLY i = 1
|
||||
DSPLY i = 2
|
||||
DSPLY i = 3
|
||||
DSPLY i = 5
|
||||
DSPLY i = 4
|
||||
DSPLY i = 3
|
||||
DSPLY i = 2
|
||||
DSPLY i = 1
|
||||
8
samples/hello.rpg
Normal file
8
samples/hello.rpg
Normal file
@@ -0,0 +1,8 @@
|
||||
CTL-OPT DFTACTGRP(*NO);
|
||||
|
||||
DCL-S greeting CHAR(25) INZ('Hello, World!');
|
||||
|
||||
DCL-PROC main EXPORT;
|
||||
DSPLY greeting;
|
||||
RETURN;
|
||||
END-PROC;
|
||||
1
samples/hello.rpg.golden
Normal file
1
samples/hello.rpg.golden
Normal file
@@ -0,0 +1 @@
|
||||
DSPLY Hello, World!
|
||||
Reference in New Issue
Block a user