Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 05:43 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: Bug with LOC() or user failure ?

Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 08:58pm 07 Oct 2021
Copy link to clipboard 
Print this post

What do we think of this one ?

> 480MHz Colour Maximite 2 G2
MMBasic Version 5.07.01
Copyright 2011-2021 Geoff Graham
Copyright 2016-2021 Peter Mather

> list "loc_test.bas"
Open "foo.txt" For Output As #1
Close #1

Open "foo.txt" For Random As #1
Print Loc(#1) ' Should be 1

Print #1, "foo";
Print Loc(#1) ' Should be 4
Close #1

Open "foo.txt" For Random As #1
Print Loc(#1) ' Should be 4 if the DOS code is a good reference
Close #1


> run "loc_test.bas"
0
0
0


Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 09:43pm 07 Oct 2021
Copy link to clipboard 
Print this post

void fun_loc(void) {
int fnbr;
getargs(&ep, 1, ",");
if(argc == 0) error("Syntax");
if(*argv[0] == '#') argv[0]++;
fnbr = getinteger(argv[0]);
   if(fnbr == 0)                                                   // accessing the console
       iret = kbhitConsole();
   else {
       if(fnbr < 1 || fnbr > MAXOPENFILES) error("File number");
       if(FileTable[fnbr].com == 0) error("File number is not open");
       if(FileTable[fnbr].com > MAXCOMPORTS) {
//            if(fmode[fnbr] & FA_WRITE){
//                iret = (*(FileTable[fnbr].fptr)).fptr + 1;
//            } else {
//             iret = RoundUptoBlock((*(FileTable[fnbr].fptr)).fptr)  -511 + buffpointer[fnbr];
//           }
       } else iret = SerialRxStatus(FileTable[fnbr].com);
   }
   targ = T_INT;
}


WTF?
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4044
Posted: 07:36am 08 Oct 2021
Copy link to clipboard 
Print this post

When fixed, shouldn't it be
0
3
3

John
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 07:45am 08 Oct 2021
Copy link to clipboard 
Print this post

  JohnS said  When fixed, shouldn't it be
0
3
3

John


It's indexed from 1 according to the manual ... and also according to MMBasic for DOS source code.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 09:10am 08 Oct 2021
Copy link to clipboard 
Print this post

Commented out one too many line. Will be fixed in next release.

Thanks for the report
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025