Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
another variation of "10 PRINT"
#11
(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.  Wink
Reply
#12
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.  Wink

yeah thats nice!

Still crappy is saying goto 10 twice. But you pay a price for one-liners.
b = b + ...
Reply
#13
(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!)
Reply
#14
(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.
Reply
#15
Nice one at @JRace,

You don't even need Screen 1 Big Grin
Code: (Select All)
_Font 8: For c = 1 To 1920: Print _IIf(Rnd < .5, "\", "/");: Next
b = b + ...
Reply
#16
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.
Reply
#17
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 + ...
Reply
#18
(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

Reply
#19
(01-12-2025, 02:52 AM)bplus Wrote: Nice one at @JRace,
You don't even need Screen 1 Big Grin
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.
Reply
#20
I struggle with using fonts in QB64
Not easy!
This is my file explorer in win 10
[Image: image.jpg]

this is the properties of the font

[Image: 1.jpg]
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

[Image: install.jpg]
Go there with the DOS command and do DIR, not there!

[Image: 3.jpg]

I don't know what I am doing wrong
                                                                                                                 
MoreCowbell(everything)
Reply




Users browsing this thread: JRace, 19 Guest(s)