[Coco] BASIC09 problem
Gene Heskett
gheskett at wdtv.com
Tue Feb 24 22:45:13 EST 2015
On Tuesday 24 February 2015 21:56:41 Bob Devries wrote:
> I'm trying to write a small procedure in Basic09 to write to the last
> sector on a disk(image). It's not working the way I thought it should.
> Maybe someone can see my error?
>
> DIM sector(256):BYTE
> DIM path:INTEGER
> DIM lof:INTEGER
> BASE 0
> OPEN #path,"/x0@":UPDATE
> GET #path,sector
> lof = sector(1)*256+sector(2) (* returns 2880 on the image I'm using *)
> SEEK #path, (lof-1)*256 (* should go to the start of the last sector *)
> (* 2880 - 1 = 2879. 2879 * 256 = 737024 *)
> GET #path, sector
> PUT #path, sector
> CLOSE #path
> END
>
> The line with SEEK #path is where it is going wrong. (lof-1)*256 returns
> 16128.
>
> I'm sure it should be a simple error in my code, but I can't see it.
>
> Regards, Bob Devries
> Dalby, QLD, Australia
The sector is a base zero number Bob, so if doing your math in decimal,
starting with LSN0, the last sector is in fact 2879. You get 2880 because
zero is a valid sector.
Cheers, Gene Heskett
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>
More information about the Coco
mailing list