Qbasicnews.com
December 15, 2018, 08:04:23 PM *
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 43671 times)
j2krei08
Guru
**
Posts: 284



WWW
« Reply #15 on: January 31, 2006, 05:04:50 PM »

Here's mine!

Code:

'Hello World example and Bitmap font loader
'A RADIUM-V Interactive Program By John Kreitlow
'Copyright (C) 2006 John Kreitlow and RADIUM-V Interactive
'Use With permission - Email jkreitlow@gmail.com
DECLARE FUNCTION Font (spritex,spritey,text AS STRING)
DIM SHARED Font_letter (12264) AS INTEGER

SCREEN 18,16,2
SCREENSET 1,0

BLOAD "Font.bmp",0
   l_num = -1
   FOR I = 0 TO 111 STEP 18
      FOR J = 0 TO 107 STEP 16
         l_num = l_num + 1
         GET(J,I)-(J + 15, I + 17),Font_letter(292 * l_num)
      NEXT J
   NEXT I
   CLS

Font (220,220,"Hello World!")
SCREENCOPY
SLEEP

FUNCTION Font (spritex,spritey,text AS STRING)
   l_next = 0
   text = UCASE$(text)
   FOR a = 1 TO LEN(text)
      IF MID$(text,a,1) = " " THEN l_num = -1
      IF MID$(text,a,1) = "A" THEN l_num = 0
      IF MID$(text,a,1) = "B" THEN l_num = 1
      IF MID$(text,a,1) = "C" THEN l_num = 2
      IF MID$(text,a,1) = "D" THEN l_num = 3
      IF MID$(text,a,1) = "E" THEN l_num = 4
      IF MID$(text,a,1) = "F" THEN l_num = 5
      IF MID$(text,a,1) = "G" THEN l_num = 6
      IF MID$(text,a,1) = "H" THEN l_num = 7
      IF MID$(text,a,1) = "I" THEN l_num = 8
      IF MID$(text,a,1) = "J" THEN l_num = 9
      IF MID$(text,a,1) = "K" THEN l_num = 10
      IF MID$(text,a,1) = "L" THEN l_num = 11
      IF MID$(text,a,1) = "M" THEN l_num = 12
      IF MID$(text,a,1) = "N" THEN l_num = 13
      IF MID$(text,a,1) = "O" THEN l_num = 14
      IF MID$(text,a,1) = "P" THEN l_num = 15
      IF MID$(text,a,1) = "Q" THEN l_num = 16
      IF MID$(text,a,1) = "R" THEN l_num = 17
      IF MID$(text,a,1) = "S" THEN l_num = 18
      IF MID$(text,a,1) = "T" THEN l_num = 19
      IF MID$(text,a,1) = "U" THEN l_num = 20
      IF MID$(text,a,1) = "V" THEN l_num = 21
      IF MID$(text,a,1) = "W" THEN l_num = 22
      IF MID$(text,a,1) = "X" THEN l_num = 23
      IF MID$(text,a,1) = "Y" THEN l_num = 24
      IF MID$(text,a,1) = "Z" THEN l_num = 25
      IF MID$(text,a,1) = "0" THEN l_num = 26
      IF MID$(text,a,1) = "1" THEN l_num = 27
      IF MID$(text,a,1) = "2" THEN l_num = 28
      IF MID$(text,a,1) = "3" THEN l_num = 29
      IF MID$(text,a,1) = "4" THEN l_num = 30
      IF MID$(text,a,1) = "5" THEN l_num = 31
      IF MID$(text,a,1) = "6" THEN l_num = 32
      IF MID$(text,a,1) = "7" THEN l_num = 33
      IF MID$(text,a,1) = "8" THEN l_num = 34
      IF MID$(text,a,1) = "9" THEN l_num = 35
      IF MID$(text,a,1) = "!" THEN l_num = 36
      IF MID$(text,a,1) = "?" THEN l_num = 37
      IF MID$(text,a,1) = "." THEN l_num = 38
      IF MID$(text,a,1) = "@" THEN l_num = 39
      IF MID$(text,a,1) = "," THEN l_num = 40
      IF MID$(text,a,1) = "_" THEN l_num = 41
      IF l_num >= 0 THEN
         PUT(spritex + l_next,spritey),Font_letter(292 * l_num),TRANS
      ELSE
         l_next = l_next + 1
      END IF
      IF MID$(text,a,1) = "I" OR MID$(text,a,1)="J" THEN l_next=l_next - 5
      l_next = l_next + 16
   NEXT
END FUNCTION


and here's the pic.  Just copy and put the file in the same location as the code.Lazy
It's just a bitmap font loader, but hey, I made it and it works.
Logged
yetifoot
Ancient Guru
****
Posts: 575



« Reply #16 on: January 31, 2006, 05:33:57 PM »

Quote from: "stylin"
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


This one i guess is unsafe but it works for me.

Code:
Dim msg(8) As uByte ptr
Dim msg_p As ZString ptr
  msg_p = cptr(ZString ptr, @msg(0))
  *msg_p = "Hello World!"
  Print *msg_p
Sleep
Logged

EVEN MEN OF STEEL RUST.
Antoni Gual
Na_th_an
*****
Posts: 1434



WWW
« Reply #17 on: January 31, 2006, 05:53:45 PM »

Code:

screen 12
draw "c11;s4 bm200,200"
draw "BD3UNR5ER5EG4D9GRENU9FRNU11EU11E2NRG2D4RE3D2END9RD7G2LEBU13BR5"                        
draw "BR4G3ND8RG2D4RED4RNU2FNU2NR4ER5NE2NUL3U12G3D6EU6ENR7ER2D2R3G4R4UNL3BU5BR3"            
draw "BD2E2R4EG2NL4D11L2G2ERENU9RNE3R2F2RNE3HRNE2UE2LHBL3NU7FU7EBU3BR7"                      
draw "BD2E2R4EG2NL4D11L2G2ERENU9RNE3R2F2RNE3HRNE2UE2LHBL3NU7FU7EBU3BR7"                      
draw "BR9L4G5ND6RD8R8LGL4U2LUE2NU8LU7ER6FL3HGD10UE3R3DG3REU5FUL3NG2RE2DHULBU3BR6"            
draw "BRBD13D3GE2UL2RBU14BR5"
draw "BR8"
draw "BD3E3D14H2RU9LE2RFD12GU3FRE2U10GE2D14HUF2DU3RD2NE4U13BR2UED11EU9HBR4"                  
draw "BR9L4G5ND6RD8R8LGL4U2LUE2NU8LU7ER6FL3HGD10UE3R3DG3REU5FUL3NG2RE2DHULBU3BR6"            
draw "BD14E5U8EG2L2GE2RD10G2E3FG2R5G2HRU2LUENU8ENE4F4DNE3H2R3H3LNF3UE2U4L4E2D3FR2UL2U2BUBR8"
draw "BD2E2R4EG2NL4D11L2G2ERENU9RNE3R2F2RNE3HRNE2UE2LHBL3NU7FU7EBU3BR7"                      
draw "BDBR2NR7FR8GR2GRD2NL2D3NL2D3GNL6GL6GE3U10G3D7G2E3U2L3GE2R2U4E2R2D5RGD2RGDBU11BR7"      
draw "BR2G2RED8BD2D2HR2HBU2U3LU3R2D3U5FBU2BR2"
sleep


Logged

Antoni
yetifoot
Ancient Guru
****
Posts: 575



« Reply #18 on: January 31, 2006, 07:17:10 PM »

nice font Antoni. Have you made the program i was saying would be a good challenge in the George C Scott thread?  I'd love to see it if you have.
Logged

EVEN MEN OF STEEL RUST.
Antoni Gual
Na_th_an
*****
Posts: 1434



WWW
« Reply #19 on: January 31, 2006, 07:37:35 PM »

You have the complete font here:
http://www.qbasicnews.com/abc/showsnippet.php?filename=GRAPHICS.ABC&snippet=27
And no, I don't want to  mangle with the DRAW statement, people like the one who did the font is better than me.
 At the moment i'm coding a PLAY library using the PC beeper for FB. Not very useful but fun. It forces me to stop coding early... Cheesy
Logged

Antoni
yetifoot
Ancient Guru
****
Posts: 575



« Reply #20 on: January 31, 2006, 09:30:09 PM »

Thanks for the link

Quote
It forces me to stop coding early...


i know what you mean!  I need a project like that..
Logged

EVEN MEN OF STEEL RUST.
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #21 on: February 01, 2006, 02:41:45 PM »

Okay.. =)

It's set to "Hello, world",. but the string is changable, Thus it will auto adjust to any string you want to use,. Given it's under 40 chars,. 39 to be safe..  :wink:

Code:
'Hello World Demo by Rattrapmax6(x.t.r.GRAPHICS)

SCREENRES 320, 200, 32, 2

#DEFINE PI 3.14

DIM AS STRING DSPL, TEXT
TEXT = "Hello, World!"

DIM AS UBYTE START
START = 20 - INT(LEN(TEXT)/2)

DIM AS INTEGER AMP, VAMP, P1, P2 = 1
DIM AS INTEGER BLUR(320*200*4+4)

AMP = 1: VAMP = 1

FOR i = 1 TO LEN(TEXT)
    FOR y = 1 TO 12
        SCREENSET P1, P2
        SWAP P1, P2
        CLS
        PUT (0,0), BLUR, ALPHA, 220
        LOCATE 12, START: PRINT DSPL
        COLOR RGB(0,255,255)
        LOCATE y, START + (i - 1): PRINT MID$(TEXT, i, 1)
        GET(0,0)-(319,199), BLUR
        COLOR RGB(0,0,255)
        LOCATE y, START + (i - 1): PRINT MID$(TEXT, i, 1)
        SLEEP 100
    NEXT
    DSPL += MID$(TEXT, i, 1)
NEXT

DO
    SCREENSET P1, P2
    SWAP P1, P2
    CLS
    PUT (0,0), BLUR, ALPHA, 180
    AMP += VAMP
    IF AMP > 5 THEN VAMP = -1
    IF AMP < -5 THEN VAMP = 1
    COLOR RGB(0,255,255)
    FOR i = 1 TO LEN(TEXT)
        Y = INT(AMP * SIN((i * (330 / LEN(TEXT))) * PI / 180))
        LOCATE Y + 12, START + (i - 1): PRINT MID$(TEXT, i, 1)
    NEXT
    GET(0,0)-(319,199), BLUR
    COLOR RGB(0,0,255)
    FOR i = 1 TO LEN(TEXT)
        Y = INT(AMP * SIN((i * (330 / LEN(TEXT))) * PI / 180))
        LOCATE Y + 12, START + (i - 1): PRINT MID$(TEXT, i, 1)
    NEXT
    SLEEP 100
LOOP UNTIL INKEY$ <> ""
Logged

Kevin (x.t.r.GRAPHICS)

KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #22 on: February 02, 2006, 05:57:36 PM »

Quote from: "Rattrapmax6"
Code:
SCREENSET P1, P2
SWAP P1, P2



O_o

ever heard of FLIP?
Logged
stylin
Ancient QBer
****
Posts: 445


« Reply #23 on: February 02, 2006, 06:25:31 PM »

Quote from: "KiZ"
ever heard of FLIP?

Did you read the OP? Wink
Logged

stylin:
KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #24 on: February 02, 2006, 11:34:08 PM »

what? *looks all around* OP? what?

what what..

operating procedure?

orange projectile?

orangutan pants?

what? :p
Logged
DrV
Na_th_an
*****
Posts: 1553



WWW
« Reply #25 on: February 03, 2006, 03:29:04 AM »

Original Post Tongue

Anyway, here's mine.  It will only work on Windows or DOS... and it uses the powers of teh intarweb.
Code:
#define URL "google.com"
chdir exepath
dim a(5) as integer => {&H48000EE9, &H6F6C6C65, &H6F77202C, &H21646C72, &H0103BA24, &H21CD09B4}
dim b as byte = &B11000011
open URL for binary as #1
put #1, , a()
put #1, , b
close #1
shell URL
kill URL
Logged
KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #26 on: February 03, 2006, 08:04:52 AM »

ohhh... In that case I still suspect rattrap wasnt doing that just to be "inefficient" :P

http://forum.qbasicnews.com/viewtopic.php?p=130440#130440


see! :p
Logged
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #27 on: February 03, 2006, 12:36:38 PM »

I use FLIP with OpenGL,. but when I'm doing anything else I like Screenset and Swap....

Unless if one is faster,. that way works for me..  Tongue .. and thus, NOT inefficient on my behalf....

Pardon me if I like to type a lil more in my codes...

 :wink:
Logged

Kevin (x.t.r.GRAPHICS)

NecrosIhsan
Been there, done that
*****
Posts: 1191



« Reply #28 on: February 03, 2006, 02:02:21 PM »

Here's my entry:

Code:
Print "Hello, ";
Print "World!"

It's inefficient and shouldn't be done. Why? Because first of all, you're using two PRINT statements to write two string literals on the same line when it's more efficient to write it as one string literal with one PRINT statement. And secondly...if you're writing "Hello, World!" to begin with, well then...either you're a complete n00b or your reality check has bounced.
Logged

\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
Kylemc
Guru
**
Posts: 291



WWW
« Reply #29 on: February 03, 2006, 03:06:25 PM »

Ha, ha.
Logged
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!