[Coco] SUBSTR issues :Is it me or Basic09 ?

Wayne Campbell asa.rand at gmail.com
Thu Aug 29 14:27:53 EDT 2019


You printed mos1, not mos. mos1 would be a REAL variable defined by use,
and because it is incorrect, it isn't holding the value of the position in
the string, but instead 0, which if you run the program again, could be any
number since Basic09 does not initialize variables automatically.

On Thu, Aug 29, 2019, 10:00 AM <coco at jechar.ca> wrote:

>
> I ran into a problem in a program I was writing which I traced to
> and incorrect value for the variable mos.
>
> So I wrote this supper short program to test the section that assigns
> mos a value.
>
> [START  CODE]
>
> PROCEDURE testmos
> (* Demo Program *)
> DIM xs$:STRING
> DIM mos:INTEGER
>
> xs$="-ip='01234567890ABCDEF'@$7"
> mos=SUBSTR(xs$,"@$")
>
> PRINT xs$
> PRINT mos1
>
> END
>
> [END CODE]
>
> When I run this code I get.
>
>
> -ip='01234567890ABCDEF'@$7
> 0
>
> What I expected was:
>
> -ip='01234567890ABCDEF'@$7
> 23
>
> So xs$ is exactly as expected but mos is not.
> Have I made a mistake I just don't see or is
> there a problem with Basic09's SUBSTR function ?
>
> Unless I am missing something there is.
>
> If the latter I am sure I can replace  it with
> half a dozen lines of code using some work around
> but  whoever is maintaining Basic09 should know
> about it. Running on a 6309 CPU.
>
> Charlie
>
>
>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>


More information about the Coco mailing list