Author Topic: lining up numbers in columns  (Read 3088 times)

0 Members and 1 Guest are viewing this topic.

FellippeHeitor

  • Guest
Re: lining up numbers in columns
« Reply #15 on: April 01, 2019, 08:08:40 pm »
Wait, where did I get this idea of there being a space on the right of a STR$(number)?

No idea :-)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: lining up numbers in columns
« Reply #16 on: April 01, 2019, 08:21:20 pm »
Ah! from this:
Code: QB64: [Select]
  1. print "Here is a number";26;"and here is another";len("Mark");", any spaces on the right side?"

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
Re: lining up numbers in columns
« Reply #17 on: April 01, 2019, 11:28:24 pm »
_TRIM it is :-)

Oh, you mean you are THINKING about making that a keyword. I wish you would have stated that in the first place, because Ive been running all through the wiki, looking for _TRIM!

Pete :D

Based on a spoof from a TV series: Hey June, where's Ward? He's running all over town looking for Beaver!

Seriously, it would save typing two keywords, like LTRIM$(STR$()) and LTRIM$(RTRIM$()), and should be a snap to implement. Nothing like the FN hell you'd have to go through to implement FN.
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

FellippeHeitor

  • Guest
Re: lining up numbers in columns
« Reply #18 on: April 01, 2019, 11:36:33 pm »
_TRIM$() is already available in the development builds and will make it to the wiki as soon as 1.3 is released ;-)

More on what's coming up here: https://www.qb64.org/forum/index.php?topic=304.msg2554#msg2554

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: lining up numbers in columns
« Reply #19 on: April 02, 2019, 01:50:34 am »
"Print using" does not work? http://qb64.org/wiki/PRINT_USING

It is really an excellent idea. Welcome to the forum RadoiHactive!

Offline Jack002

  • Forum Regular
  • Posts: 123
  • Boss, l wanna talk about arrays
Re: lining up numbers in columns
« Reply #20 on: April 02, 2019, 12:15:27 pm »
Years ago I would make a fn called trim that was rtrim and ltrim together. I assume this is what we're discussing?

STR$ will make a space to the left of the number. I have often done a mid$ 2 of it just to zap it. Trim also works.
QB64 is the best!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
Re: lining up numbers in columns
« Reply #21 on: April 02, 2019, 05:05:37 pm »
STR$() actually doesn't make the space. The space is already there. It just doesn't get rid of it. Try print 1. You'll see the 1 is indented one space to the left. Now try print 2. You see the - sign is on the margin, followed by the 1. So the computer language just formats numbers in this manner, preserving a space in case a negative is involved. At least that's my non-schooled take on the matter. As the the trailing space that STR$() does trim off, well, I used to know what that was for, but I have to admit, I've forgotten!

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/