Quick Pascal Bug Page Below are listed some problems discovered so far, and interim solutions until they are addressed in future releases.

Bug - Error 248

(5/17/98) This occurs when the RAM disk (/r0) gets full (version 0.6b only). I first noticed it while converting a large Pascal source file.

Solution. 1. Try to free up room by deleting files on the RAM disk. If you aren't planning on doing immediate translations and assemblies, you can remove PascalDefs from the RAM disk. 2. Don't load translator, swap and asm programs, then allocate more space to your RAM disk. This is done by deiniz Gene's RAM driver, then using dmode to set sct to a higher value, followed by iniz RAM.

Fix. I will probably put in an option for converting files to a location of the user's choice, the path of which will likely be established in qp.init file. Also need to catch error 248, else Quick Pascal quits!


Getting Strings

(5/17/98) OS-9 Pascal is ISO compliant, which means there's no STRING type. So, you have to make one yourself, reading in one character at a time and adding it to an ARRAY OF CHAR. Here's an example:
PROGRAM string; 
 
{ Note: the statement 'PACKED' is optional on 6X09 machines, }
{ but is checked for proper syntax by the compiler.}    
 
{ Define a string array to hold 10 characters }
TYPE string10=PACKED ARRAY [1..10] OF CHAR; 
 
VAR word:string10; 
    count,loop:INTEGER; 
    letter:CHAR; 
    
BEGIN 
    count:=1; 

    { have the user input characters one at a time, }
    { then put them into 'word' }
    WHILE (count<=10) AND NOT EOLN DO BEGIN 
        READ (letter); 
        word[count]:=letter; 
        count:=count+1
    END; {while} 
    
    { pad the rest of the array with spaces }
    FOR loop:=count TO 10 DO 
        word[loop]:=' '; 

    { write the output }
    WRITE ('Hello, ');
    WRITELN(word);

END. {string}


Getting the System Time

Here's an example of getting the system time by using OS-9 Pascal's SYSTIME standard procedure. See page 7-3 of the OS-9 Pascal Manual.

PROGRAM timedate; 
 {example of getting system time & date from OS-9}

TYPE str10 = ARRAY[1..10] OF CHAR; 
     str2  = ARRAY[1..2]  OF CHAR; 
     
VAR yy,mm,dd,hr,min,sec:INTEGER; 
    month:str10; 
    morn: str2; 
    
BEGIN 
    
    { use OS-9 Pascal procedure to get system time }
    SYSTIME(yy,mm,dd,hr,min,sec); 

    {set month based upon value of mm}
    CASE mm OF 
        1:month:='   January'; 
        2:month:='  February'; 
        3:month:='     March'; 
        4:month:='     April'; 
        5:month:='       May'; 
        6:month:='      June'; 
        7:month:='      July'; 
        8:month:='    August'; 
        9:month:=' September'; 
        10:month:='   October'; 
        11:month:='  November'; 
        12:month:='  December'; 
    END; {case} 

    {is it am or pm?}
    morn:='am'; 
    IF hr>11 THEN BEGIN 
        morn:='pm'; 
        hr:=hr-12; 
    END; {if} 
    IF hr=0 THEN 
        hr:=12; 
 
    {now just write it out}
    WRITE (month:10,dd:3,', 19':4,yy:2,'  ':2,hr:2,':':1,min:2,morn:3); 
    WRITELN; 
END. {timedate}
 

Use of Files and 2D Arrays

The following program shows how to use file access and 2d array to compute mean and standard deviation. The file 'data' must be an array of 12 numbers across and 8 numbers down (96 numbers total).

PROGRAM stddev; 
 
{ calculates and prints standard deviation of two numbers } 
 
VAR 
    num1, 
    num2, 
    mean, 
    deviance, 
    sumofdev, 
    variance, 
    stddev: 
        REAL; 
    i, 
    j: 
        INTEGER; 

    {declare a 2D array, 12 across by 8 down }
    eiarray: ARRAY [1..8,1..12] OF REAL; 

    {declare a text file for reading}
    datafile: TEXT; 
         
{******************************************************************} 
    PROCEDURE getstddev (num1,num2:REAL); 
    {this procedure computes mean and sample standard deviation }
    {from numeric pairs and writes the results out to stdout }

        BEGIN 
         
            mean := (num1 + num2) / 2; 
            deviance := 0; 
            sumofdev := 0; 
    
            deviance := (num1 - mean) * (num1 - mean); 
            sumofdev := sumofdev + deviance; 
    
            deviance := (num2 - mean) * (num2 - mean); 
            sumofdev := sumofdev + deviance; 
    
            variance := sumofdev / 1; 
            stddev:= SQRT(variance); 
    
            WRITELN(num1:6:3,'  ', num2:6:3,'  ',stddev:6:4); 
        END; { getstddev } 
 
{******************************************************************} 
 
BEGIN 
    {look for file named 'data' on /r0.  This contains 96 numbers }
    {in a 12 x 8 array }
    RESET (datafile, '/r0/data'); 
    
    {get the numbers from datafile (/r0/data) }
    {and read into the array 'eiarray' }
    FOR i:=1 TO 8 DO BEGIN 
        FOR j:=1 TO 12 DO BEGIN 
            {get the number}
            READLN (datafile,eiarray[i,j]);
            {write it to stdout} 
            WRITE(eiarray[i,j]:6:3); 
        END; { for j } 
        {CR and LF}
        WRITELN; 
        {put a space between each row}
        WRITELN; 
    END; { for i } 
    
    PAGE; {eject to next page}

    {compute standard deviation of across pairs}
    WRITELN (' Calculating Standard Deviations');    
    WRITELN; 
    WRITELN (' Val 1   Val 2  StdDev'); 
    WRITELN ('======  ======  ======'); 
    WRITELN; 
    
    i:=1; 
    WHILE i < 8 DO BEGIN 
        FOR j:=1 TO 12 DO BEGIN 
            {pass two adjacent numbers to getstddev}
            getstddev(eiarray[i,j],eiarray[i+1,j]); 
        END; { for j } 
        i:=i+2; 
    END; { while } 
    
END.