A couple questions from a PureBasic user

Started by Quin, June 11, 2024, 10:14:20 PM

Previous topic - Next topic

Quin

I'm coming at this from a fairly unique angle, I've heard of very few PureBasic programmers abandoning it in favor of BCX, but I'm here. I'm still not sure if it'll fully replace PB for me, I have multiple 10K LOC+ projects in PB, but for new projects, this looks amazing. I do have a couple questions/comments though:
1. The captcha on your forum acts horribly with screen readers, like I myself use. The audio only autoplays in Chrome (not even Edge), it breaks with text-based browsers like edbrowse, and the downloading just downloads as index(copy).wav. This happens all over the place and is honestly expected by most screen reader users, but it's still not fun. IMO, if we're a logged in, registered user we don't really need a captcha to post anyways ;)
2. How can I convert a number like 192834 into something like "one hundred ninety two thousand eight hundred thirty four?"
3. What's the best way to install everything? I installed the IDE, but it seems to be on 8.0.8, not 8.1.0, which is the absolute latest.
Thanks!
-Quin.
GitHub

MrBcx

#1
Quote from: Quin on June 11, 2024, 10:14:20 PM
I'm coming at this from a fairly unique angle, I've heard of very few PureBasic programmers abandoning it in favor of BCX, but I'm here. I'm still not sure if it'll fully replace PB for me, I have multiple 10K LOC+ projects in PB, but for new projects, this looks amazing. I do have a couple questions/comments though:

1. The captcha on your forum acts horribly with screen readers, like I myself use. The audio only autoplays in Chrome (not even Edge), it breaks with text-based browsers like edbrowse, and the downloading just downloads as index(copy).wav. This happens all over the place and is honestly expected by most screen reader users, but it's still not fun. IMO, if we're a logged in, registered user we don't really need a captcha to post anyways ;)

2. How can I convert a number like 192834 into something like "one hundred ninety two thousand eight hundred thirty four?"

3. What's the best way to install everything? I installed the IDE, but it seems to be on 8.0.8, not 8.1.0, which is the absolute latest.
Thanks!

Good evening Quin and welcome,

I visited your github page (https://github.com/TheQuinbox) and know a bit about you from what you shared on that page.

You are the first PureBasic user that I'm aware of having taken an interest in BCX.  Moments ago I approved another membership
request from someone (tspivey) also linked to NVDA, perhaps you two know each other.  We'll find out soon enough, I suppose.

Regarding your questions:

1) Once approved, as you have been, when you log in to the forum, there is a combobox next to your credentials with options
to stay logged in for an hour, a day, a week, a month, or forever.
  Forever seems like a good choice, if you're are comfortable
with the security aspect of that choice.

2) ChatGPT generated most of the following code just a few minutes ago.  I tweaked it into BCX submission:

192834
one hundred ninety two thousand eight hundred thirty four
Press any key to continue . . .



'****************
' Test the code
'****************
DIM TestNumber
DIM TestResult$

TestNumber = 192834
TestResult$ = NumToWords$(TestNumber)

PRINT TestNumber
PRINT TestResult
PAUSE

FUNCTION NumToWords$ (Number AS LONG)
    DIM Units$ [10]
    DIM Teens$ [10]
    DIM Tens$ [10]
    DIM Thousands$ [5]
    DIM Result$
    DIM Num

    Units$[0] = "zero"
    Units$[1] = "one"
    Units$[2] = "two"
    Units$[3] = "three"
    Units$[4] = "four"
    Units$[5] = "five"
    Units$[6] = "six"
    Units$[7] = "seven"
    Units$[8] = "eight"
    Units$[9] = "nine"

    Teens$[0] = "ten"
    Teens$[1] = "eleven"
    Teens$[2] = "twelve"
    Teens$[3] = "thirteen"
    Teens$[4] = "fourteen"
    Teens$[5] = "fifteen"
    Teens$[6] = "sixteen"
    Teens$[7] = "seventeen"
    Teens$[8] = "eighteen"
    Teens$[9] = "nineteen"

    Tens$[2] = "twenty"
    Tens$[3] = "thirty"
    Tens$[4] = "forty"
    Tens$[5] = "fifty"
    Tens$[6] = "sixty"
    Tens$[7] = "seventy"
    Tens$[8] = "eighty"
    Tens$[9] = "ninety"

    Thousands$[1] = "thousand"
    Thousands$[2] = "million"
    Thousands$[3] = "billion"
    Thousands$[4] = "trillion"

    IF Number = 0 THEN
        FUNCTION = Units$[0]
    END IF

    IF Number < 0 THEN
        Result$ = "negative "
        Number = ABS(Number)
    END IF

    Num = Number

    IF Num >= 1000 THEN
        Result$ = Result$ + NumToWords$(Num/1000) + " " + Thousands$[1] + " "    ' <<<---  A recursive call
        Num = MOD(Num, 1000)
    END IF

    IF Num >= 100 THEN
        Result$ = Result$ + Units$[Num/100] + " hundred "
        Num = MOD(Num, 100)
    END IF

    IF Num >= 20 THEN
        Result$ = Result$ + Tens$[Num/10] + " "
        Num = MOD(Num, 10)
    END IF

    IF Num >= 10 THEN
        Result$ = Result$ + Teens$[Num-10] + " "
        Num = 0
    END IF

    IF Num > 0 THEN
        Result$ = Result$ + Units$[Num] + " "
    END IF

    Result$ = TRIM$(Result$)

    FUNCTION = Result$
END FUNCTION



If you already installed bcx_install.zip, you will regularly find Announcements that a new Bc.exe and BcxHelp.chm is available.

Download those when they are available and overwrite the old one in whatever path you installed BCX into.

I am the person who maintains the translator ( Bc.exe ) and Robert Wishlaw maintains the BcxHelp.chm

The Announcements area on the forum will contain download links.  I always provide a 32-bit and a 64-bit
version of Bc.exe.  (A few of our users still used 32-bit versions of Windows).  Be sure to use the version that is
appropriate for your operating system.

Don't hesitate to ask questions, if you get stumped.  We have hundreds of examples to help get your feet wet.



Quin

I indeed did bring a friend along, yup. :)
I'm coming from PB and am quite impressed (maybe that says more about PB though?). For example, one BCX feature PB is lacking is nested WITH blocks, which are super nice.
I noticed in your example that you added all the array elements on their own lines. Is there no literal syntax for arrays? That's honestly fairly expected out of BASIC-like languages, AutoHotkey spoiled me a tiny bit.
Also... this is one huge thing with PB... do we have a ternary operator? :D
Thanks for the great replies, and I look forward to participating more here!
-Quin.
GitHub

Robert

Quote from: Quin on June 11, 2024, 11:38:32 PM
I indeed did bring a friend along, yup. :)
I'm coming from PB and am quite impressed (maybe that says more about PB though?). For example, one BCX feature PB is lacking is nested WITH blocks, which are super nice.
I noticed in your example that you added all the array elements on their own lines. Is there no literal syntax for arrays? That's honestly fairly expected out of BASIC-like languages, AutoHotkey spoiled me a tiny bit.
Also... this is one huge thing with PB... do we have a ternary operator? :D
Thanks for the great replies, and I look forward to participating more here!

Literal syntax for arrays ?

Check out SET ... END SET

https://bcxbasiccoders.com/webhelp/html/setstatement.htm

Quin

-Quin.
GitHub

MrBcx

Quote from: Quin on June 11, 2024, 11:38:32 PM

Also... this is one huge thing with PB... do we have a ternary operator? :D


BCX allows us to embed C/C++ code using the "!" (exclamation point) operator.  This idea
originated with TurboBasic / PowerBasic which used the operator to embed Intel ASM code
directly into a BASIC source file.  Therefore, if you have anything that can't be coded using BCX
directly but it can be coded in c/c++, you have an avenue to make it work.

Check this out:



DIM age AS INT
PRINT "Here's an example of embedded C ternary operator in BCX"
PRINT
INPUT "Please enter your age? ", age
PRINT

! (age >= 18) ? printf("Person Can Vote\n\n") : printf("Person Cannot Vote\n\n");

PRINT "Wasn't that easy?"
PAUSE




Additionally, BCX has the IFF() and IFF$()  built-in functions which, although
are not operators, they do provide a functional parallel to the ternary operator.

Reference:  https://bcxbasiccoders.com/webhelp/html/iiffunction.htm


Quin

This, good sir, has just sold me.

PureBasic also has inline C, but it's way messier because you can't include any headers, you can't do blocks of C code like I believe you can here with something like #CPPCODE, and it's overall just blech. Benifits to being a translator, not a proprietary tool, I suppose ;)
-Quin.
GitHub

MrBcx

Quote from: Quin on June 12, 2024, 03:02:05 PM
This, good sir, has just sold me.

PureBasic also has inline C, but it's way messier because you can't include any headers, you can't do blocks of C code like I believe you can here with something like #CPPCODE, and it's overall just blech. Benifits to being a translator, not a proprietary tool, I suppose ;)

That's cool ... the more you use BCX, the more comfortable and familiar it will become.