Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:09 01 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 : FORMAT$ ?

Author Message
BobC
Newbie

Joined: 10/06/2017
Location: United States
Posts: 9
Posted: 12:43pm 09 Aug 2017
Copy link to clipboard 
Print this post

All,

My first post here since getting into MM.

I've seen code posted on Fruit of the Shed that uses FORMAT$. I see that in later versions of MMBasic this seems to be gone. I'm trying to format some output from
an 18B20 to be "xx.xx". My current code outputs up to 4 digits right of the DP.
I'd like to trim that to just 2. I'm sure there is an easy way to do it, I've just not found it yet.
Not an expert Basic programmer here, still getting my feet wet with MMBasic.

I'm using Rob's E28 platform sampled by Stan/Rob and a few of Mick's MuP V2's that I've built. Great hardware! I am a convert from PICAXE and Arduino to MM's. Love them.

Thanks!

Bob
WA1EDJ
Monroe, GA USA
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 01:08pm 09 Aug 2017
Copy link to clipboard 
Print this post

Welcome to the shed.

You are correct, FORMAT$ is only in the maximites (V4.5 and earlier)

Have a look at the options in STR$
That will do what you require and is a bit simpler to use.

You probably want STR$(x,3,2) if you allow for negative numbers.

Jim
VK7JH
MMedit
 
BobC
Newbie

Joined: 10/06/2017
Location: United States
Posts: 9
Posted: 02:07pm 09 Aug 2017
Copy link to clipboard 
Print this post

Thanks Jim, I'll give it a try....Bob
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1993
Posted: 05:45pm 09 Aug 2017
Copy link to clipboard 
Print this post

If you want it to stay as a numeric variable you can use,
Temp = Int(Temp*100)
Temp = Temp/100

Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
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