Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Curious if I am thinking about this right.
#21
(Yesterday, 08:20 PM)bplus Wrote: "Oh you speed demo" ah, Charlie I had so much less typing to do Smile
That is freak'n interesting code you had back there @CharlieJV
https://qb64phoenix.com/forum/showthread...6#pid31416
I see your Input can take variable string for/in the prompt And something funny about IF THEN Structure there too.
I must warn newbies that this BAM code is NOT QB64pe code but a very close cousin.
Oh, that should have been "speed demon"


There's nothing really "BAM-required" about my code.  I could style the code exactly as you would for QB64PE.

Program in BAM as if you were using GW-BASIC or QBASIC.  BAM allows me to format/organize code in a way that accommodates my challenges, but nobody else has to program that way in BAM.
-$60.00
Reply
#22
(Yesterday, 08:20 PM)bplus Wrote: "Oh you speed demo" ah, Charlie I had so much less typing to do Smile

That is freak'n interesting code you had back there @CharlieJV
https://qb64phoenix.com/forum/showthread...6#pid31416

I see your Input can take variable string for/in the prompt And something funny about IF THEN Structure there too.
I must warn newbies that this BAM code is NOT QB64pe code but a very close cousin.

Hey, silly question.  What about the BAM code I shared would not work in QB64PE ?
Reply
#23
(Yesterday, 08:12 PM)bplus Wrote: the dueting continues

"Wrong direction"  ??? me with a true one-liner single statement showing another feature of QB64pe that can not be found in that other vesion of QB64.
Low bytes is good too, for sure!, but that is another direction ("colonscopey" let's call it) which I don't dare call "wrong", just a little misguided maybe. Smile

Code: (Select All)
Print Val(_InputBox$("Convert number from inches to mm.", "Enter a number")) * 25.4

Wrong direction in the fact that you went from a fully functional program to one that now does only half the required work in that single line of code. The above only converts from inches to mm, but it can't convert from mm to inches. It might be half the lines of what you had before, but it does half the work as well. I'd consider that going in the "wrong direction" in the code. You want to compare apples to apples, not apples to half-apples. Wink

I don't see any way to get full functionality and do both processes in a single line of code, without using a colon to cram multiple statements on that line. Maybe later tonight I'll brainstorm something crazy to do so, but I doubt it. Tongue

(8 hours ago)CharlieJV Wrote: Hey, silly question.  What about the BAM code I shared would not work in QB64PE ?

There's no INPUT _IFF format with QB64PE. Wink
Reply
#24
Quote:There's no INPUT _IFF format with QB64PE.  Wink

That's an INPUT statement followed by a string (well, the IFF results in a string)

QB64PE has INPUT, and doesn't the INPUT statement's first parameter allow a string?  Can't the string be a variable or the result string of a function ?  And the latest version of QB6PE has an IFF function, right?

What am I missing ?
Reply
#25
Oops, apologies.

I thought INPUT's first parameter in QB64 could handle string expressions.

Just tested and the INPUT statement's first parameter must be a string literal.


AND:  I forgot that BAM's INPUT statement works exactly as QB64 in that regard.  But not for  much longer ...
Reply
#26
@bplus I wracked my poor brain to death, and I finally came up with a single line of code that does everything -- both inch to mmm AND mm to inch conversion.  Big Grin

Code: (Select All)
Print _IIf(Shell("@echo off & set /P input=Please enter a value with positive for inch and negative for millimeter: & echo|set /p=%input%|clip") <> 0 Or Val(_Clipboard$)<0, str$(Val(_Clipboard$) / -25.4)+" inches", str$(Val(_Clipboard$) * 25.4) + " millimeters")


And that is one loooong line of code, fit only for the brain exercise, and not one that anyone should ever really study up on and try to learn from.  LOL!

Give it a positive number to go from inch to mm.  Give it a negative number to go from mm to inch.  One command, tweaked completely insanely, to do everything within a single line of code and not colon cheating involved.  Big Grin
Reply
#27
(8 hours ago)SMcNeill Wrote:
(Yesterday, 08:12 PM)bplus Wrote: the dueting continues

"Wrong direction"  ??? me with a true one-liner single statement showing another feature of QB64pe that can not be found in that other vesion of QB64.
Low bytes is good too, for sure!, but that is another direction ("colonscopey" let's call it) which I don't dare call "wrong", just a little misguided maybe. Smile

Code: (Select All)
Print Val(_InputBox$("Convert number from inches to mm.", "Enter a number")) * 25.4

Wrong direction in the fact that you went from a fully functional program to one that now does only half the required work in that single line of code. The above only converts from inches to mm, but it can't convert from mm to inches. It might be half the lines of what you had before, but it does half the work as well. I'd consider that going in the "wrong direction" in the code. You want to compare apples to apples, not apples to half-apples. Wink

I don't see any way to get full functionality and do both processes in a single line of code, without using a colon to cram multiple statements on that line. Maybe later tonight I'll brainstorm something crazy to do so, but I doubt it. Tongue

(8 hours ago)CharlieJV Wrote: Hey, silly question.  What about the BAM code I shared would not work in QB64PE ?

There's no INPUT _IFF format with QB64PE. Wink

Well so Steve can get a good nights sleep tonight:
Code: (Select All)
Print Val(_InputBox$("Convert number from inches to mm.", "Enter a number")) * 25.4, Val(_InputBox$("Convert number from mm to inches.", "Enter a number")) / 25.4

It's up to the user if he wants to enter the same number both times, so hey it's a little more flexible. Big Grin
b = b + ...
Reply
#28
(7 hours ago)bplus Wrote: Well so Steve can get a good nights sleep tonight:
Code: (Select All)
Print Val(_InputBox$("Convert number from inches to mm.", "Enter a number")) * 25.4, Val(_InputBox$("Convert number from mm to inches.", "Enter a number")) / 25.4

It's up to the user if he wants to enter the same number both times, so hey it's a little more flexible. Big Grin

Beat you to it. Try my insane code above yours. Big Grin
Reply
#29
@CharlieJV yeah you got it about the Input statement, a major fix allowing variable strings with more variables for a prompt. Another plus would be the ability to paste in the user part. Steve did one like that.

Still the screenshot you showed had a weird thing going with If Then it looked like there was some missing code too that might explain why it looked weird.

(7 hours ago)SMcNeill Wrote:
(7 hours ago)bplus Wrote: Well so Steve can get a good nights sleep tonight:
Code: (Select All)
Print Val(_InputBox$("Convert number from inches to mm.", "Enter a number")) * 25.4, Val(_InputBox$("Convert number from mm to inches.", "Enter a number")) / 25.4

It's up to the user if he wants to enter the same number both times, so hey it's a little more flexible. Big Grin

Beat you to it. Try my insane code above yours. Big Grin

So what are we telepathically connected? I was just watching a show on TV about that! Spooky
b = b + ...
Reply




Users browsing this thread: 11 Guest(s)