[Coco] new problem with unpack

Aaron Wolfe aawolfe at gmail.com
Tue Nov 5 16:15:11 EST 2013


FWIW - This works:


BASE 0

DIM a1(10):BYTE
DIM a2(1):STRING[10]
DIM i:INTEGER

FOR i=0 TO 9
   a1(i) = 65
NEXT i

a2 = a1

PRINT a2(0)

(prints AAAAAAAAAA)



On Tue, Nov 5, 2013 at 2:51 PM, Wayne Campbell <asa.rand at gmail.com> wrote:
> It appears that one of the features of Basic09 is not a feature after all.
> According to the Basic09 Reference for OS-9 Level 2:
>
> Chapter 11: Basic09 Command Reference: LET
> ================================================================================
> Use BASIC09’s assignment function to copy entire arrays or complex data
> structures to another array or complex data structure. The data structures
> do not need to be of the same type or shape, but the size of the
> destination structure must be the same as or larger than the source
> structure. This means the assignment function can perform unusual type
> conversions. For example, you can copy a string variable of 80 characters
> into a one-dimensional array of 80 bytes.
> ================================================================================
>
> In the Level 1 Basic09 Manual it says:
>
> Chapter 9: Program Statements and Structure: Assignment Statements: LET
> ================================================================================
> Another use of the assignment statement is to copy the entire value of an
> array or complex data structure to another array or complex data structure.
> The data structures do not have to have the same type or "shape". The only
> restriction is that the size of the destination structure be the same or
> larger than the source structure. In fact this type of assignment can be
> used to perform unusual type conversions. For example, a string variable of
> 80 characters can be copied to a one-dimensional array of 80 bytes.
> ================================================================================
>
> Neither manual provides an example of this usage. I tried assigning a
> string to an array and vice-versa. I even went back to OS-9 Level 2
> original disk image and tried it with Basic09 01.00.01. The assignment does
> not work in OS-9 or in NitrOS-9. It returns a ERROR #071. In ErrorCodes,
> the message is:
>
> Error#: 71 Illegal Expression Type
>
> Here is a sample program to try. If you have a real CoCo2 or CoCo3, and you
> run NitrOS-9 L1 or L2, please try this program. I need to know what happens
> on the real hardware.
>
> PROCEDURE LETtest
> (* Remember that the keyword LET is optional *)
> (* This procedure will use assignments both with and without it *)
> (* I tried inserting BASE 1 and changing arrayStr length to 11 *)
> (* with no change in the result *)
>
> DIM array(10):BYTE
> DIM arrayStr:STRING[10]
> DIM posCount:INTEGER
>
> (* array will contain 0123456789 *)
> FOR posCount:=1 TO 10
>   array(posCount):=posCount-1
> NEXT posCount
>
> arrayStr:=array \! error 71
> PRINT arrayStr
>
> arrayStr:="9876543210"
> LET array:=arrayStr \! error 71
> FOR posCount:=1 TO 10
>   PRINT array(posCount);
> NEXT posCount
> PRINT
>
> END
>
> Load errors:
>
> 00C4 ERROR #071 Illegal Expression Type
> 00E4 ERROR #071 Illegal Expression Type
>
> Error lines:
>
> 00BD arrayStr:=array <- C4 is the <eol> token
> 00C5 PRINT arrayStr
>
> 00DC LET array:=arrayStr <- E4 is the <eol> token
> 00E5 FOR posCount:=1 TO 10
>
> Runtime error:
>
> ERROR #051 Line with Compiler Error
>
> So, while I am supposed to be able to do these types of assignments,
> Basic09 does not, in fact, allow it. At least, not in VCC or in MESS. Note
> that neither assignment statement shows an error in the editor. The syntax
> is considered valid by Basic09's editor.
>
> I believe that this functionality may have existed in L1 Basic09
> (v01.00.00), but I do not have a copy to test with. I do, however, have a
> copy of v01.00.01. Using that one I found the same error occurs. It is as
> though this feature never really existed, but it could be that whatever
> changed between v01.00.00 and 01.00.01 took away this feature.
>
> I welcome any input that can help dispel this confusion. Does anyone else
> on this list have experience with this form of assignment in Basic09?
>
> Wayne
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> http://five.pairlist.net/mailman/listinfo/coco



More information about the Coco mailing list