Work needed on FORMAT$?

28 views
Skip to first unread message

Guy1954

unread,
May 28, 2017, 6:20:38 PM5/28/17
to xblite
Hi Xbliters.

Since I got tired of coding "RIGHT$ ("00" + STRING$(month), 2)" to get January being displayed as "01",
I expended the standard Xblite function FORMAT$ in order to add the syntax: "FORMAT$ ("00", month)".

Since the source of FORMAT$ is in source file .\xblib\XFORMAT.x,
I added format code '0' to right-justify numbers, which works just like '*',
except padding with leading zeroes instead of '*'.

In doing so, I discovered 2 bugs:
- Bug 1. FORMAT$ ("***#", 2015) => Good: "2015"   bad: "**%2015"
- Bug 2. FORMAT$ ("****", 2015) => Good: "2015"   bad "****"

Then, I tried all the examples in the Xblite manual to check for regressions.
And actually, half of the examples failed.

I went back to the original version, and I observed the same fails.

I wrote a little GUI application, and I suggest that some of you try it on their Xblite environment.
FORMAT$ is a great function and I would miss it if it were broken (I remember of the same fate with Visual Basic 6).

Attached are:
- test.vxn: viXen's project
- test.x: demo program to show some of function FORMAT$()'s possibilities.

Could you please download them, compile test.x with xsed and execute test.exe in your machine?
The more feedback from you, the best I can evaluate if we should work on a new and improved version of FORMAT$,
just like D. asked us in the past for another standard function: XstReplace().

Hope you'll pick up the challenge.

Bye! Guy
test.x
test.vxn

Guy1954

unread,
May 28, 2017, 6:40:23 PM5/28/17
to xblite

Hi David W.

You are the Xbasicer of our group of Xbliters, and I'd like to benefit for your expertise.

I could notice that Xbasic maintainers coded some enhencement in function FORMAT$.
It looked to me that:
1.They corrected some bugs,
2.They could have implemented my new format character '0'.

For your benefit, I recoded the same test application, but for Xbasic generation.




Attached are:
- test.vxn: viXen's project

- test.x: a skeleton of what I think you need to add for a Xui application, the Xbasic way.

Your feedback as an Xbasicer will be a big help.

Thank you in advance for your time.


Bye! Guy

test.vxn
test.x

David Szafranski

unread,
May 29, 2017, 4:03:48 PM5/29/17
to xbl...@googlegroups.com
There is not a bug here, you need to use the * modifier correctly.
* is not a place holder like #, it is like $. You would not use
multiple $$$ in a format string.

So you never need to use more than one * in your format string:

  a$ = FORMAT$ ("*###", 2015)
  a$ = FORMAT$ ("*###", 115)
  a$ = FORMAT$ ("*###", 15)
  a$ = FORMAT$ ("*###", 5)
  a$ = FORMAT$ ("*####", 2015)

You will always get some kind of error if you try to use more than one
* character in the format string. You also get an error if the format string is
too short for the value to be formatted.

D.

Guy1954 wrote:
--
You received this message because you are subscribed to the Google Groups "xblite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xblite+un...@googlegroups.com.
To post to this group, send email to xbl...@googlegroups.com.
Visit this group at https://groups.google.com/group/xblite.
For more options, visit https://groups.google.com/d/optout.

Guy1954

unread,
May 29, 2017, 4:31:15 PM5/29/17
to xblite
Hi D.

My mistake! I'll take in account your input ASAP.

Bye! Guy

Guy1954

unread,
May 29, 2017, 4:43:10 PM5/29/17
to xblite

Hi David W.

I made some improvements to the Xbasic generator in viXen.

If you want to benefit from them, get the latest version of viXen, which I just uploaded at SourceForge.


Then, you can run viXen against the test.vxn that I uploaded for a preview of test.x (also uploaded just for you...)


Bye! Guy

Guy1954

unread,
May 29, 2017, 5:38:26 PM5/29/17
to xblite
Hi Xbliters.

I took in account D.'s comment and I corrected the Windows GUI application accordingly.
Could you please download the attached test.x and run it in your Xblite environment?

You will notice that there are 2 radio buttons:
- the top one refers to Xblite's FORMAT$();
- the bottom one to an INTERNAL XxxFormat$()
  (with the new format character '0': new FORMAT$ ("00", 1)).

Both should yield to the same result, except for case # 14.

Bye! Guy
test.x

Guy1954

unread,
May 29, 2017, 5:43:38 PM5/29/17
to xblite
Same to you, David "Xbasic" W: I corrected your Xbasic version of test.x, except that I took Xbasic's version of XxxFormat$().

Please, download your test.x and good luck to you to make it a Xui application.
(Easy for you, impossible for me!)

As a bonus, I improved viXen so that you can prime with a better Xui skeleton.

Bye! Guy
test.x

David Silverwood

unread,
Jun 12, 2017, 8:46:16 AM6/12/17
to xbl...@googlegroups.com
Hi Guy
When I try and compile the 'revised' version I get the following error...
0x80005889 $$SYSCON
I normally get that when there is a reference somewhere that doesn't exist, though I cannot find anything in that line in the code...


--
You received this message because you are subscribed to the Google Groups "xblite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xblite+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages