Qbasicnews.com
December 15, 2018, 01:40:46 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 43661 times)
yetifoot
Ancient Guru
****
Posts: 575



« Reply #45 on: February 09, 2006, 12:38:08 PM »

@DRV yes very clever way!! i was fooled for a moment that it DID use the internet.

PS.  it says HVllo World
Logged

EVEN MEN OF STEEL RUST.
DrV
Na_th_an
*****
Posts: 1553



WWW
« Reply #46 on: February 15, 2006, 05:27:44 AM »

Oops, typo (swapped 56 for 65)... fixed. Smiley
Logged
E.K.Virtanen
Senior Member
**
Posts: 166



WWW
« Reply #47 on: March 28, 2006, 04:37:57 PM »

Too simple ones i just made.

1'st
Code:
SCREEN 18 : Width 80,60

DIM Text(2) AS STRING
    Text(1) = "Hello_" : Text(2) = "World"

DIM n, x, r AS INTEGER

For r = 1 TO 2
   LOCATE 1,1 : Print Text(r)

For n = 0 TO LEN(Text(1)) * 8
  For x = 0 TO 7
     IF POINT(n, x) > 0 THEN
LOCATE x+(10*r),n+(1+(r*8)) : Color x + 23 : Print CHR$(177);
PSET(n, x), 0 : Sleep 50
     END IF
  Next x
Next n
Next r
Sleep


2'nd
Code:

Randomize Timer
CLS
DIM WeWantThis AS STRING
    WeWantThis = "HelloWorld"
For i = 1 TO LEN(WeWantThis)
DO
IsCorrect = INT(RND * 57) + 66
LOCATE 10,i : Print CHR$(IsCorrect);
SLEEP 100
LOOP Until MID$(WeWantThis,i,1) = CHR$(IsCorrect)
Next i
SLEEP
Logged

url=http://www.ascii-world.com]ASCII-World.com[/url]
Yeah, nick changed from lurah, but bullshit's are the same.
Nathan1993
Member
*
Posts: 83


« Reply #48 on: February 18, 2007, 08:21:58 PM »

Code:
type Node
'The address of the node before us
PrevNode as Node ptr
'The address of the node after us
NextNode as Node ptr
'The data in this node
NodeData as string
end type

declare sub SetNodeData(byref Node as Node ptr, byval NodeData as string)
declare sub DestroyNode(byref Node as Node ptr)
declare sub DestroyList(byref NodeHead as Node ptr)
declare function AddNode(byref CurrentNode as Node ptr, byval NodeData as string) as Node ptr
declare function GetNextNode(byref Node as Node ptr) as node ptr
declare function GetNodeData(byref Node as Node ptr) as string
declare function GetPrevNode(byref Node as Node ptr) as Node ptr



sub SetNodeData(byref Node as Node ptr, byval NodeData as string)
Node->NodeData = NodeData
end sub

sub DestroyNode(byref Node as Node ptr)
'We need to make 2 node ptrs
'one for the node after us, and
'one for the node before us
dim as Node ptr PrevNode, NextNode

'Get the address of the node before
'and after us
PrevNode = GetPrevNode(Node)
NextNode = GetPrevNode(Node)

'If we don't have a node before us, don't update
'the node before us
if NextNode <> 0 then
'We need to tell it that the node before it is
'the node before Node -- not Node itself
NextNode->PrevNode = PrevNode
end if

'Make sure we arn't accessing a null pointer
if PrevNode <> 0 then
'We need to tell the node before us that
'the node after us is it's next node
PrevNode->NextNode = NextNode
end if

'Get rid of our Node
deallocate(Node)
end sub
sub DestroyList(byref NodeHead as Node ptr)
dim as Node ptr CurrentNode = NodeHead
dim as Node ptr NextNode
dim as integer i = 1
do while GetNextNode(CurrentNode) = 0
NextNode = GetNextNode(CurrentNode)
DestroyNode(CurrentNode)
CurrentNode = NextNode
loop
end sub
function AddNode(byref CurrentNode as Node ptr, byval NodeData as string) as Node ptr
'Make a new node and give it the space of a Node type
dim as Node ptr NewNode = callocate(len(Node))

'Give the new node the data that we were told to
NewNode->NodeData = NodeData

'Give the old node the address of the new node
CurrentNode->NextNode = NewNode

'Set our current node to the one we made
return NewNode
end function
function GetNextNode(byref Node as Node ptr) as node ptr
if Node->NextNode <> 0 then
return Node->NextNode
else
return Node
end if
end function

function GetNodeData(byref Node as Node ptr) as string
return Node->NodeData
end function
function GetPrevNode(byref Node as Node ptr) as Node ptr
if Node->PrevNode <> 0 then
return Node->PrevNode
else
return Node
end if
end function





'Make the head of the node
dim as Node ptr ListHead = callocate(len(Node))

'Make our first node with the data of "Hello"
dim as Node ptr CurrentNode

'Put some data into our nodes
CurrentNode = AddNode(ListHead, "Hello")
CurrentNode = AddNode(CurrentNode, " ")
CurrentNode = AddNode(CurrentNode, "world!")

'Lets traverse through our 3 nodes and get out our data
CurrentNode = GetNextNode(ListHead)
print GetNodeData(CurrentNode);
CurrentNode = GetNextNode(CurrentNode)
print GetNodeData(CurrentNode);
CurrentNode = GetNextNode(CurrentNode)
print GetNodeData(CurrentNode)

DestroyList(ListHead)[list]

Actually an accident -- I wrote this and just had to post this, as I remembered about this thread.[/list]
Logged

f a fly walked, would it be called a walk?
Why dosn't someone make a word that rymes with purple or orange?
WHY AM I SO ANNOYING? Becuase I wanna!
Why am I typeing this? Cuz im bored!
stylin
Ancient QBer
****
Posts: 445


« Reply #49 on: February 20, 2007, 03:18:16 AM »

Inspired by the movie War Games:

Code:
'' compile with fbc version
dim target as string = "Hello, world!"
dim matches(0 to len(target) - 1) as integer
dim numMatches as integer = 0
dim test as string = space(13)

randomize timer
cls
do
dim i as integer
for i = 0 to len(target) - 1
if not matches(i) then
do
test[i] = int(rnd * 256)
loop while test[i] < 32

if test[i] = target[i] then
matches(i) = -1
numMatches += 1
end if
end if
next

locate 1,1 : print test : sleep 50

if numMatches = len(target) then exit do
loop
Logged

stylin:
Skyler
Ancient Guru
****
Posts: 564



« Reply #50 on: February 20, 2007, 10:34:21 AM »

Code:

PRINT "G";
PRINT "O";
PRINT "O";
PRINT "D";
PRINT "B";
PRINT "Y";
PRINT "E";
PRINT " ";
PRINT "C";
PRINT "R";
PRINT "U";
PRINT "E";
PRINT "L";
PRINT " ";
PRINT "W";
PRINT "O";
PRINT "R";
PRINT "L";
PRINT "D";
PRINT "!";
PRINT " "
PRINT "*glug glug glug*"
SLEEP


It works in FB.  :lol:
Logged

In the beginning, there is darkness the emptiness of a matrix waiting for the light. Then a single photon flares into existence. Then another. Soon, thousands more. Optronic pathways connect, subroutines emerge from the chaos, and a holographic consciousness is born." -The Doctor
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!