Qbasicnews.com
October 23, 2018, 12:00:17 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2 3 4
  Print  
Author Topic: Your best "Hello, world!" program in FreeBasic  (Read 42967 times)
stylin
Ancient QBer
****
Posts: 445


« on: January 26, 2006, 05:12:18 AM »

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
Logged

stylin:
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #1 on: January 26, 2006, 06:10:56 AM »

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!
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #2 on: January 26, 2006, 12:59:21 PM »

[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 :>
Logged
TheDarkJay
I hold this place together
*****
Posts: 913



WWW
« Reply #3 on: January 26, 2006, 01:15:21 PM »

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
Logged

url=http://www.sloganizer.net/en/][/url]
thegrogen
Ancient QBer
****
Posts: 444



« Reply #4 on: January 26, 2006, 01:57:27 PM »

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
Logged

.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
DefHo
Member
*
Posts: 74



« Reply #5 on: January 26, 2006, 04:32:37 PM »

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.
Logged

hat were we arguing about again?
SSC
Guru
**
Posts: 288



WWW
« Reply #6 on: January 28, 2006, 04:09:22 AM »

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 =)
Logged

url=http://www.smithcosoft.com]SmithcoSoft Creations[/url]
"If you make it idiot proof, someone will make a better idiot" - Murphy's Law
DefHo
Member
*
Posts: 74



« Reply #7 on: January 28, 2006, 05:09:51 AM »

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!!! Cheesy
Logged

hat were we arguing about again?
thegrogen
Ancient QBer
****
Posts: 444



« Reply #8 on: January 28, 2006, 05:37:15 PM »

Quote from: "SSC"
*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.
Logged

.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
SSC
Guru
**
Posts: 288



WWW
« Reply #9 on: January 28, 2006, 07:31:05 PM »

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
Logged

url=http://www.smithcosoft.com]SmithcoSoft Creations[/url]
"If you make it idiot proof, someone will make a better idiot" - Murphy's Law
KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #10 on: January 29, 2006, 12:38:49 AM »

Quote from: "DefHo"
Hand over my @$ cookie!!! :D


hehe, ok so It wasnt too hard to work out with good code reading ^.^

Here you go!
Logged
DefHo
Member
*
Posts: 74



« Reply #11 on: January 29, 2006, 04:07:41 PM »

Mmm. That was tasty. Thanks.
Logged

hat were we arguing about again?
yetifoot
Ancient Guru
****
Posts: 575



« Reply #12 on: January 30, 2006, 02:32:29 AM »

Code:
Dim As Integer dd(704) = { _
 41,  74,  41,  76,  41,  82,  41,  85,  41,  90,  41,  95,  41, 100,  41, 102, _
 41, 107,  41, 111,  41, 114,  41, 117,  41, 120,  41, 125,  41, 127,  41, 132, _
 41, 136,  41, 140,  41, 143,  41, 147,  41, 151,  41, 152,  41, 153,  41, 154, _
 42, 114,  44, 114,  48, 114,  50, 114,  54, 114,  60, 114,  65, 114,  68, 114, _
 70, 114,  71, 114,  75,  79,  75,  80,  75,  85,  75,  93,  75, 102,  76, 111, _
 76, 118,  76, 125,  76, 127,  76, 134,  76, 138,  76, 140,  76, 141,  96, 130, _
 98, 129, 100, 128, 100, 127, 103, 125, 105, 124, 106, 122, 108, 121, 108, 120, _
108, 119, 108, 118, 108, 117, 108, 116, 108, 115, 108, 114, 108, 113, 107, 112, _
107, 111, 106, 111, 105, 110, 103, 110, 102, 110, 100, 110,  97, 110,  92, 113, _
 88, 117,  83, 119,  81, 121,  81, 122,  80, 123,  80, 124,  80, 127,  80, 129, _
 82, 131,  82, 132,  84, 135,  86, 137,  88, 140,  91, 141,  95, 144,  99, 145, _
101, 145, 103, 145, 106, 145, 108, 145, 112, 144, 114, 143, 116, 142, 116, 141, _
132,  82, 132,  86, 132,  93, 132,  96, 132, 103, 132, 108, 132, 114, 132, 120, _
132, 126, 132, 132, 132, 134, 132, 140, 132, 143, 132, 144, 151,  89, 151,  93, _
151,  95, 151, 100, 151, 105, 151, 111, 151, 117, 151, 123, 151, 128, 151, 131, _
151, 136, 151, 142, 151, 146, 151, 148, 183, 118, 181, 118, 179, 119, 178, 120, _
174, 126, 172, 128, 171, 132, 170, 134, 170, 138, 170, 140, 171, 142, 174, 144, _
177, 146, 179, 146, 182, 146, 184, 146, 187, 145, 189, 144, 192, 141, 194, 139, _
195, 134, 195, 130, 195, 126, 195, 123, 193, 119, 190, 115, 188, 114, 185, 112, _
244,  84, 244,  85, 244,  87, 244,  91, 244,  97, 244, 102, 245, 107, 245, 113, _
246, 115, 248, 120, 250, 127, 252, 131, 254, 137, 254, 139, 254, 141, 254, 142, _
254, 143, 254, 144, 254, 145, 254, 146, 255, 144, 255, 143, 256, 141, 257, 139, _
258, 137, 260, 133, 262, 130, 262, 127, 262, 125, 263, 123, 263, 122, 263, 121, _
263, 120, 263, 119, 263, 120, 263, 122, 264, 124, 266, 129, 270, 136, 274, 142, _
276, 145, 278, 147, 279, 147, 280, 145, 281, 141, 281, 136, 281, 131, 281, 124, _
281, 122, 281, 115, 281, 108, 281, 102, 282,  98, 283,  94, 283,  92, 283,  91, _
283,  90, 283,  88, 283,  87, 283,  86, 311, 123, 309, 123, 307, 123, 305, 125, _
304, 125, 303, 128, 302, 131, 301, 133, 301, 136, 301, 140, 302, 142, 303, 144, _
305, 145, 307, 147, 309, 148, 311, 148, 313, 148, 316, 148, 317, 147, 320, 146, _
321, 145, 321, 143, 322, 142, 322, 139, 322, 137, 322, 134, 322, 131, 321, 128, _
319, 127, 318, 125, 316, 125, 339, 125, 339, 128, 339, 130, 339, 134, 339, 140, _
339, 142, 339, 144, 339, 141, 339, 135, 339, 131, 339, 126, 339, 122, 339, 119, _
339, 118, 339, 117, 340, 117, 341, 116, 345, 116, 349, 116, 352, 116, 355, 116, _
380, 100, 380, 104, 380, 110, 380, 116, 380, 122, 380, 126, 380, 133, 380, 137, _
380, 141, 380, 144, 380, 145, 380, 146, 404, 130, 403, 129, 401, 129, 400, 128, _
399, 128, 397, 128, 395, 130, 392, 133, 391, 137, 390, 141, 390, 143, 390, 145, _
390, 146, 391, 146, 392, 146, 394, 146, 397, 146, 400, 145, 402, 142, 404, 141, _
406, 138, 407, 138, 407, 135, 408, 131, 408, 127, 408, 121, 408, 117, 408, 113, _
408, 110, 408, 107, 408, 104, 408, 102, 408, 100, 408,  99, 408,  97, 408,  96, _
408,  95, 408,  94, 408,  93, 408,  92, 408,  91, 408,  90, 408,  93, 409, 101, _
412, 115, 417, 129, 421, 142, 426, 153, 427, 158, 427, 162, 428, 162, 452,  93, _
452,  96, 452,  98, 452, 101, 452, 106, 452, 113, 452, 118, 452, 124, 452, 130, _
452, 131, 452, 133, 451, 150, 450, 150, 449, 150, 448, 151, 446, 154, 446, 155, _
445, 157, 445, 159, 445, 160, 446, 161, 447, 161, 448, 159, 450, 156, 452, 151 }

ScreenRes 640, 480, 32

For i = 1 To 704 Step 2
  mx = dd(i-1)
  my = dd(i)
  pset (mx, my), &HFFFFFF
  pset (mx + 1, my + 1), &HFFFFFF
  pset (mx - 1, my - 1), &HFFFFFF
  pset (mx + 1, my - 1), &HFFFFFF
  pset (mx - 1, my + 1), &HFFFFFF
  Sleep 20
Next i

Sleep
Logged

EVEN MEN OF STEEL RUST.
LooseCaboose
I hold this place together
*****
Posts: 981



« Reply #13 on: January 30, 2006, 03:54:53 AM »

Compiles for FB, QB and ANSI C:
Code:

REM; /*
print "Hello World"
'*/ int main(void) {printf("Hello World\n"); return 0;}


Edit: Slightly more clever version:
Code:

REM = '\t'; char *PRINT = "\n"; /*
DIM s AS STRING * 13
'*/ int main() { char *s[3] = {
PRINT , "Hello world",
REM}; printf("%c%s%s", s[2], s[1], s[0]);}
Logged

esus saves.... Passes to Moses, shoots, he scores!
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #14 on: January 30, 2006, 05:34:07 AM »

Cute cross-language stuff, I like it, very classy Cheesy
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Pages: [1] 2 3 4
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!