Posts: 2,759
Threads: 332
Joined: Apr 2022
Reputation:
231
(01-12-2025, 12:41 AM)bplus Wrote: I was going for a one-liner like the original that didn't need the _Font 8 to fix the print.
I think what you wanted was something more like this then:
Code: (Select All)
10 screen 1: cnt = cnt + 1: If cnt < 1921 Then If Rnd < .5 Then Print "\";: GoTo 10 Else Print "/";: GoTo 10
Single line of code, no use of _Font 8... Several screen modes default to font 8, and Screen 1 is one of those.
Posts: 4,080
Threads: 181
Joined: Apr 2022
Reputation:
232
01-12-2025, 12:53 AM
(This post was last modified: 01-12-2025, 01:00 AM by bplus.)
The higher the colon count the crappier the line of code, usually.
For assignments, it makes sense until QB64pe allows commas in such lines.
a = 1, b = 2, ...
(01-12-2025, 12:48 AM)SMcNeill Wrote: (01-12-2025, 12:41 AM)bplus Wrote: I was going for a one-liner like the original that didn't need the _Font 8 to fix the print.
I think what you wanted was something more like this then:
Code: (Select All)
10 screen 1: cnt = cnt + 1: If cnt < 1921 Then If Rnd < .5 Then Print "\";: GoTo 10 Else Print "/";: GoTo 10
Single line of code, no use of _Font 8... Several screen modes default to font 8, and Screen 1 is one of those.
yeah thats nice!
Still crappy is saying goto 10 twice. But you pay a price for one-liners.
b = b + ...
Posts: 231
Threads: 5
Joined: Apr 2022
Reputation:
25
01-12-2025, 02:03 AM
(This post was last modified: 01-12-2025, 02:17 AM by JRace.)
(01-12-2025, 12:53 AM)bplus Wrote: Still crappy is saying goto 10 twice. But you pay a price for one-liners.
Who needs GOTO?
For that matter, who needs IF...THEN...ELSE?
Quote:Code: (Select All)
Screen 1: _Font 8: For c = 1 To 1920: Print _IIf(Rnd < .5, "\", "/");: Next
(In the world of C, I've always enjoyed deeply nesting ternary operators, imagining the reactions of people who will have to maintain the code later. Debugging them sux, but nesting them is fun.)
Of course the name TenPrint would no longer make sense.
(Forget one-liners; with functions like _IIF to abuse I'm getting ideas about an Obfuscated Basic contest!)
Posts: 2,759
Threads: 332
Joined: Apr 2022
Reputation:
231
(01-12-2025, 02:03 AM)JRace Wrote: (01-12-2025, 12:53 AM)bplus Wrote: Still crappy is saying goto 10 twice. But you pay a price for one-liners.
Who needs GOTO?
For that matter, who needs IF...THEN...ELSE?
Quote:Code: (Select All)
Screen 1: _Font 8: For c = 1 To 1920: Print _IIf(Rnd < .5, "\", "/");: Next
(In the world of C, I've always enjoyed deeply nesting ternary operators, imagining the reactions of people who will have to maintain the code later. Debugging them sux, but nesting them is fun.)
Of course the name TenPrint would no longer make sense.
(Forget one-liners; with functions like _IIF to abuse I'm getting ideas about an Obfuscated Basic contest!)
In this case, you don't even need the _Font 8. Screen 1 defaults to font 8.
Posts: 4,080
Threads: 181
Joined: Apr 2022
Reputation:
232
01-12-2025, 02:52 AM
(This post was last modified: 01-12-2025, 02:57 AM by bplus.)
Nice one at @JRace,
You don't even need Screen 1
Code: (Select All) _Font 8: For c = 1 To 1920: Print _IIf(Rnd < .5, "\", "/");: Next
b = b + ...
Posts: 231
Threads: 5
Joined: Apr 2022
Reputation:
25
01-12-2025, 03:11 AM
(This post was last modified: 01-12-2025, 03:13 AM by JRace.)
Thanks yet again, Hero Steve!
Now let's eliminate the PE-specific _IIF:
Quote:Code: (Select All)
Screen 1: For c = 1 To 1920: Print Mid$("\/", (Rnd < .5) + 2, 1);: Next
(Notice I'm still trying to keep it at least mildly obfuscated.)
This should now run on QB and (with the addition of a line number) GWBasic.
Posts: 4,080
Threads: 181
Joined: Apr 2022
Reputation:
232
01-12-2025, 03:23 AM
(This post was last modified: 01-12-2025, 03:25 AM by bplus.)
Here's another way. also skips the IF's
Code: (Select All) Font 8: For c = 1 To 1920: Print Chr$(47 + -45 * (Rnd < .5));: Next
also closer to Original 10 Print: Code: (Select All) 10 PRINT CHR$(205.5+RND(1)); : GOTO 10
b = b + ...
Posts: 2,759
Threads: 332
Joined: Apr 2022
Reputation:
231
01-12-2025, 03:24 AM
(This post was last modified: 01-12-2025, 03:26 AM by SMcNeill.)
(01-12-2025, 03:11 AM)JRace Wrote: Thanks yet again, Hero Steve!
Now let's eliminate the PE-specific _IIF:
Quote:Code: (Select All)
Screen 1: For c = 1 To 1920: Print Mid$("\/", (Rnd < .5) + 2, 1);: Next
(Notice I'm still trying to keep it at least mildly obfuscated.)
This should now run on QB and (with the addition of a line number) GWBasic.
How about this version for something that works in all basics and should have people scratching their heads trying to sort it out without running it first:
Code: (Select All)
_Font 8: For i = 1 To 1920: Print Chr$(Int(Rnd * 2) * 45 + 47);: Next
Or use a different Screen mode as we don't want _Font (which is QB64 specific):
Code: (Select All)
Screen 8: For i = 1 To 1920: Print Chr$(Int(Rnd * 2) * 45 + 47);: Next
Posts: 231
Threads: 5
Joined: Apr 2022
Reputation:
25
01-12-2025, 03:47 AM
(This post was last modified: 01-12-2025, 03:50 AM by JRace.)
(01-12-2025, 02:52 AM)bplus Wrote: Nice one at @JRace,
You don't even need Screen 1
Code: (Select All) _Font 8: For c = 1 To 1920: Print _IIf(Rnd < .5, "\", "/");: Next
Technically we don't need the Screen or Font statements since it still prints the same characters, but the results just don't look the same on a vanilla screen with a vanilla font:
vs:
@SMcNeill & @bplus I was about to post my old GWBasic port of TenPrint, but you both beat me to it. It's pretty much the same as your last posts.
Posts: 16
Threads: 2
Joined: Jan 2025
Reputation:
1
I struggle with using fonts in QB64
Not easy!
This is my file explorer in win 10
this is the properties of the font
This line gives the error invalid handle
mfont = _LoadFont(Environ$("HOME") + "/.local/share/fonts/CousineNerdFontMono-Bold.ttf", ps, "UNICODE")
So does this line
mfont = _LoadFont(Environ$("HOME") + "/windows/fonts/CousineNerdFontMono-Bold.ttf", ps, "UNICODE")
/windows/fonts/
is right where the ttf file is!
Is it installed? I think so, I did install it. You right click and PREVIEW and on that screen press INSTALL. I did it, it is GREY
Go there with the DOS command and do DIR, not there!
I don't know what I am doing wrong
MoreCowbell(everything)
|