Qbasicnews.com

Full Version: Your best "Hello, world!" program in FreeBasic
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
Simple. Post a neat "Hello, world!" program. It does not necessarily have to be obfuscated, but should be clever, inefficient, unsafe or otherwise something you shouldn't be doing. Wink

The output must only be "Hello, world!" (without quotes).

You may submit more than one entry - and are encouraged to do so - but you cannot post consecutive entries; you must wait until at least one entry has been posted before posting again.

There are no prizes; everyone is a winner. I'll start:

Code:
'' : HelloWorld.bas :
'' -----------------------------------------------------------------------------
dim _l(3) as double => { 1.0795350776197, 2.68322932786768, _
                         0.926115152769539, 0.717391304347826 }

dim as zstring * 14 _O => "Goodbye, sol."

    dim as longint _0 => &hfeedface
    dim as longint _1 => &hdeadbeef
    
    while(_1 <_0 )
        _0 = *cptr( integer ptr, @_O[O_*4] ) * _l(O_)
        O_ += 1 : print *cptr( zstring ptr, @_0 ) ;
        _0 += _1-O_*10
    wend

    sleep : end O_-4
I can't get a bit of your code.

Are you sure that's BASIC? :lol: Wink

That's what I made in 5 minutes, I don't have more than that. It sucks, but looks kinda cool

Code:
#define World : Locate , 8 - 1 :? "World!" : Obfuscation = 0
#define Hello Print "Hello Hello!"

Hello, World!
[syntax="qbasic"]#define gcfp(num) (val(mid(str(pi), num, 1)))
#define gwfp(num1, num2, num3) (chr(val(str(gcfp(piref(num1))) + str(gcfp(piref(num2))) + str(gcfp(piref(num3))))))

dim piref(7) as integer => {7, 13, 15, 4, 1, 8, 3, 0}
dim shared pi as double

pi = 1
add = 1

for i = 1 to 27
add = add + 2
pow = pow + 1
if sign then pi = pi + (add * 3 ^ pow) ^ -1 else pi = pi - (add * 3 ^ pow) ^ -1
sign = sign xor 1
next
pi = 2 * sqr(3) * pi


print gwfp(7, 2, 5) + gwfp(6, 7, 6) + gwfp(6, 7, 1) + gwfp(6, 7, 1) + gwfp(6, 6, 6) + gwfp(7, 3, 3);
print gwfp(7, 4, 5) + gwfp(6, 6, 0) + gwfp(6, 6, 6) + gwfp(6, 6, 3) + gwfp(6, 7, 1) + gwfp(6, 7, 7) + gwfp(7, 4, 4)

sleep[/syntax]

I'll give you a cookie if you can work out how it works ^^

Hint: it uses Pi :>
My personal favorite

Code:
#define FacK Print
#define You "Hello"
#define Mother +
#define Facker "World"

Fack You Mother Facker

SLEEP

You have to replace the A in Fack and Facker with a u
Code:
s:                        
Sleep 500
If Inkey$ = "" Then Goto h
End
l3:
Print "l";
Goto d
o1:
Print "o";
Goto sp
l2:
Print "l";
Goto o1
o2:
Print "o";
Goto r
e:
Print "e";
Goto l1
d:
Print "d"
Goto s
h:
Print "H";
Goto e    
sp:
Print " ";
Goto w
l1:
Print "l";
Goto l2
w:
Print "w";
Goto o2
r:
Print "r";
Goto l3
Code:
DECLARE FUNCTION bin2string$ (a$)
DECLARE FUNCTION string2bin$ (a$)

SCREEN 13

'create data
COLOR 1
PALETTE 1, 0
PRINT "Hello world!"
buffer$ = ""
FOR x = 0 TO 95
  FOR y = 0 TO 7
    IF POINT(x, y) THEN buffer$ = buffer$ + CHR$(1) ELSE buffer$ = buffer$ + CHR$(0)
  NEXT
  realbuffer$ = realbuffer$ + bin2string$(buffer$)
  buffer$ = ""
NEXT

CLS

'display data
OUT 968, 1
OUT 969, 63
OUT 969, 63
OUT 969, 63

FOR x = 0 TO 95
  buffer$ = string2bin$(MID$(realbuffer$, x + 1, 1))
  FOR y = 0 TO 7
    IF ASC(MID$(buffer$, y + 1, 1)) THEN PSET (x, y), 1
  NEXT
NEXT

sleep

FUNCTION bin2string$ (a$)
  'decodes a series of 8 digits (0 or 1) into an ascii character
  ch = 0
  inc = 1
  FOR i = 1 TO 8
    IF ASC(MID$(a$, i, 1)) THEN ch = ch + inc
    inc = inc * 2
  NEXT
  bin2string$ = CHR$(ch)
END FUNCTION

FUNCTION string2bin$ (a$)
  'encodes an ascii character into its binary format
  binr = 0
  n = 128
  DO
    IF binr < ASC(a$) THEN
      IF binr + n <= ASC(a$) THEN
        binr = binr + n
        b$ = b$ + CHR$(1)
      ELSE
        b$ = b$ + CHR$(0)
      END IF
    ELSE
      b$ = b$ + CHR$(0)
    END IF
    n = n / 2
  LOOP UNTIL n < 1
  'reverse the string
  b2$ = ""
  FOR i = 8 TO 1 STEP -1
    b2$ = b2$ + MID$(b$, i, 1)
  NEXT
  string2bin$ = b2$
END FUNCTION
EDIT: oops, that's qbasic. It should work in freebasic though.
Code:
dim array(0 to 319, 0 to 199)
screen 13
print "Hello World!"
for x = 0 to 319
    for y = 0 to 199
        array(0 to 319, 0 to 199) = point(x,y)
    next
next
cls
screen 12
for x = 0 to 319
    for y = 0 to 199
        pset(x,y),array(x,y)
    next
next
sleep
hehe screen 13 font in screen 12 resolution =)
Quote:I'll give you a cookie if you can work out how it works ^^

gfpw (7, 2, 5) returns "H" (ascii character 72).
gfpw (6, 7, 6) returns "e"
etc...

piref (7) = 0
piref (2) = 15
piref (5) = 8

The first character in pi or mid(str(pi), 0, 1) is " " (It's not 3 because of the space at the beginning of the string. str(pi) = " 3.14159...")
The 16th character in pi or mid(str(pi), 15, 1) is "7"
The 9th character in pi or mid(str(pi), 8, 1) is "2"

Put them together and you get " 72"


Hand over my fucking cookie!!! Big Grin
Quote: *removed code*
hehe screen 13 font in screen 12 resolution =)

Code:
dim array(319, 199)
screen 13
print "Hello World!"
for x = 0 to 319
    for y = 0 to 199
        array(x, y) = point(x,y)
    next
next
cls
screen 12
for x = 0 to 319
    for y = 0 to 199
        pset(x,y),array(x,y)
    next
next
sleep

Fixed.
hmm? , if you make a print after screen 12 has opened then its a different text size then the one made in 13 displayed on 12
Pages: 1 2 3 4 5 6