Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:00 04 Jul 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 : LOC and LOF...

Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9586
Posted: 02:45am 23 Jan 2015
Copy link to clipboard 
Print this post

Two exceptionally handy functions in MMBASIC are LOC and LOF.

I've had a bit of a look around on the net, but I am unable to find out what these commands are actually short for.

It is only academic, but do the letters LOC and LOF "Mean" something or are they short for something?

Most of the other keywords make sense, such as LEN(length), DIM(dimension) FOR/NEXT, DO/LOOP etc, but these two serial port commands have always made me wonder what the letters are actually short for.......


Smoke makes things work. When the smoke gets out, it stops!
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4033
Posted: 03:26am 23 Jan 2015
Copy link to clipboard 
Print this post

LOC = location I always understood, but seems to have morphed weirdly.

Don't think LOF existed back then!

John
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3282
Posted: 03:59am 23 Jan 2015
Copy link to clipboard 
Print this post

Originally LOC meant the read location in a random access file and LOF meant the length of a file. But when they were applied to COM ports the meanings morphed into something else.

Perhaps you should ask Bill to explain!

Geoff
Geoff Graham - http://geoffg.net
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 03:59am 23 Jan 2015
Copy link to clipboard 
Print this post

RTFM.:)
[code]
For a file this will return the current length of the file in bytes
[/code]

LOF = Length Of File



Microblocks. Build with logic.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9586
Posted: 03:10pm 23 Jan 2015
Copy link to clipboard 
Print this post

Thanks for those posts, guys - it is all useful and interesting information.

LOF has really made me very happy in my latest experiment. The PICAXE would send the data, THEN execute the next command. MMBASIC does not - it drops the data to send into the buffer, then executes the next command right away, while the TXD buffer is being emptied in the background - that is fabulous, as it allows my code to move to something else, and the PIC32 empties the buffer in the background - wonderful, and serial messaging bliss.

Although, it did take a SMALL amount of head scratching at first, to find out why the RF module was only "Blipping" when I sent it the data.

Pseudo PICAXE code was:


Enable RF module
SEROUT data to module
Disable RF module


When I ported that across to MMBASIC:


Pin(14)=1 'Enable RF module
Print #1,"UUUUUUUUUUTESTING RF MODULES." + chr$(13)
Pin(14)=0


...MMBASIC was disabling the RF module before it could actually send the data!

The addition of the line Do:Loop until LOF(#1)=256 solved that problem, and I now have plans to put a quick check of something else inside that loop, so MMBASIC can check something else while it is waiting for the serial buffer to empty, THEN it can disable the RF module.

Beautiful.
Smoke makes things work. When the smoke gets out, it stops!
 
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