Page 1 of 1

Formatting money with a dollar sign

Posted: Thu Jul 04, 2019 6:55 am
by Azzurosky
Is there a way to ensure that the dollar sign is immediately to the left of an amount of money when output?

E.g.

X=12345
PRINT "$#####" : X

Prints $12345, which is fine.

But if X is 345 then it prints $ 345, inserting two spaces after the $ sign.

How can I ensure that the $ sign is immediately to the left of the first digit? In some versions of Basic using $$ solves the problem, but that doesn't appear to work in Smart Basic

Re: Formatting money with a dollar sign

Posted: Thu Jul 04, 2019 11:08 am
by Mr. Kibernetik
The simplest way is:

Code: Select all

x=345
print "$"&x