flat assembler
Message board for the users of flat assembler.

flat assembler > Examples and Tutorials > Hobby Basic for Windows

Goto page Previous  1, 2, 3  Next
Author
Thread Post new topic Reply to topic
MajorDill



Joined: 01 Nov 2010
Posts: 18
when I click on download nothing is there. Just learning fasm and could really use these examples.

begging somebody to repost them

thankyou
Post 26 Apr 2014, 18:04
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1256
Location: In a West End town
Hi MajorDill,

Sorry about this. I'm building my website but it will take me longer than expected. See the 1st post.


Last edited by Picnic on 29 Aug 2014, 19:32; edited 2 times in total
Post 26 Apr 2014, 21:40
View user's profile Send private message Reply with quote
MajorDill



Joined: 01 Nov 2010
Posts: 18
got it - thanks
Post 28 Apr 2014, 14:01
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1256
Location: In a West End town
BASIC Commands
Code:
    rem
    print
    input
    goto
    gosub
    return
    if...then...else
    do...until
    for...to...{step}...next
    while...endw
    on...gosub
    break
    end
    


A set of special console commands is available to make things easier.
These commands return values to reserved variables V0,V1,V2,V3.
See ReadMe.txt for more information.

Code:
    ! Get mouse information

    do

        mouse

        ! V0 = cell x
        ! V1 = cell y
        ! V2 = button: 1 left, 2 right, 4 double click
        ! V3 = coordinates in pixels (high/low order word)

        title V0,",",V1

        wait 1

    until key(27)<>0
    


Last edited by Picnic on 03 Nov 2018, 11:33; edited 43 times in total
Post 31 Jul 2015, 06:16
View user's profile Send private message Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 547
I love this stuff. Excellent materials for beginners to learn from (although there's nothing 'beginners' with the code)
Post 01 Aug 2015, 02:54
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 547
I am linking to this thread.
Post 01 Aug 2015, 03:10
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1256
Location: In a West End town
^^Thank you fasmnewbie.

The 'Hello World' program in Hobby Basic.
Code:
    cls
    for i=1 to 15
        pen i
        locate i,i
        print "Hello World!"
    next i
    inkey
    


Last edited by Picnic on 03 Nov 2018, 11:28; edited 21 times in total
Post 02 Aug 2015, 11:15
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1256
Location: In a West End town
Arrays are 1D and 2D with the pointer starting from 0. Elements of an array are
either signed integer values or strings. The size of an array changes dynamically
by calling DIM again. The initial values of the elements of an array are set to 0.
Code:
    dim a[5]=10,20,30,0x40,50h

    for i=0 to 4
        print "a[",i,"] is ",a[i]
    next
    pause
    


Code:
    dim a[3,3]

    dim b[3,3]=10,20,0x1E,40,50,60,70,80,1011010b

    a[]=b[]   ! copy array

    for y=0 to 2
        for x=0 to 2
        print "a[",x,",",y,"] is ",a[x,y]
        next
    next
    pause
    


Code:
    dim a$[10]="Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct"

    dim a$[12]    ! resize array

    a$[10]="Nov"

    a$[11]="Dec"

    n=size(a$[])  ! get array size

    for i=0 to n-1
        print "a$[",i,"] = ",a$[i]
    next
    pause
    


Last edited by Picnic on 09 Sep 2018, 15:26; edited 18 times in total
Post 12 Aug 2015, 09:43
View user's profile Send private message Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 547
Picnic

It would be very nice if you could share your passion with Tomasz and others at Programming Language & Design section where you can properly introduce your Hobby Basic to the community. Good to see FASM is becoming a language of choice for compiler writing.
Post 12 Aug 2015, 12:43
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1256
Location: In a West End town
^^I feel it's early for that now. The interpreter is far for being complete. Surely i might do that but in later time.


A label is identified by the symbol # at the end of a name. Comments in the
source code start with the symbol ! or the REM command.
Code:
    retry#

    ! line comment
    rem  line comment

    input "Secret number:",n
    if n<>1234 then goto retry
    end
    


Code:
    for x=1 to 3
        on x gosub L1,L2,L3
    next
    pause
    end

    L1# print "Label 1":return
    L2# print "Label 2":return
    L3# print "Label 3":return
    


Anonymous Labels.
Code:
    @@#

    !  @@ followed by # create an anonymous label
    !  goto @b  (backward jump)
    !  goto @f  (forward jump)
    !  Ctrl-C to exit loop

    goto @b
    


Last edited by Picnic on 09 Sep 2018, 15:27; edited 10 times in total
Post 15 Aug 2015, 22:13
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1256
Location: In a West End town
A string variable is identified by the symbol $ at the end of a name.
Concatenation uses the + addition symbol to add parts to a string variable.
Code:
    age=10
    a$="I am "+chr(34)+str(age)+chr(34)+" years old."
    print a$
    pause
    


Code:
    a$="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    b$=reverse(a$)
    print a$,EOL$,b$
    print left(a$,5)
    pause
    


Code:
    input "How many words:",n
    dim a$[n]

    for i=0 to n-1
        print "Enter word ",i+1,":",
        input a$[i]
    next
    pause
    


Code:
    do
        input "password:",a$
    until comp(trim(a$),"letmein")=1
    print "You are in."
    pause
    


Last edited by Picnic on 09 Sep 2018, 15:27; edited 22 times in total
Post 03 Sep 2015, 14:45
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1256
Location: In a West End town
A set of built-in functions is available. These functions return either an
integer value, or a string. A variable for storing the return value must
always precede the function call, unless a print command exists.

Code:
    ! abs(n)                    --> int
    ! asc(a$)                   --> int
    ! base(n,radix)             --> string
    ! bin(n)                    --> string
    ! cell(x,y)                 --> int
    ! chr(n)                    --> string
    ! comp(a$,b$)               --> int
    ! find(a$,find$,[start])    --> int
    ! hex(n)                    --> string
    ! key(n)                    --> int
    ! lcase(a$)                 --> string
    ! left(a$,length)           --> string
    ! len(a$)                   --> int
    ! mid(a$,start,length)      --> string
    ! pad(a$,char,length)       --> string
    ! path([arg])               --> string
    ! pow(x,y)                  --> int
    ! readln(n,path$)           --> string,V0
    ! replace(a$,find$,text)    --> string
    ! reverse(a$)               --> string
    ! insert(a$,pos,text)       --> string
    ! right(a$,length)          --> string
    ! size([arg])               --> int
    ! split(a$,delim,array$[])  --> int
    ! rnd(n)                    --> int
    ! spc(n)                    --> string
    ! str(n)                    --> string
    ! tick([n])                 --> int
    ! trim(a$)                  --> string
    ! ucase(a$)                 --> string
    ! val(a$)                   --> int


    x=VAL("510")/2              ! x=255
    x=ASC("hello")              ! x=104 (ASCII of 'h')
    x=FIND("abcdefg","de")      ! x=4
    x=TICK()                    ! x=tick counter
    ? CHR(65)                   ! prints 'A'
    ? "0x",UCASE(HEX(255))      ! prints "0xFF"
    ? RIGHT("Hello",2)          ! prints "lo"
    ? LCASE("HELP Me")          ! prints "help me"
    ? PATH(1)                   ! HB path (e.g., "C:\HB")
    do:wait 1:until KEY(27)     ! waits until key Esc
    


Last edited by Picnic on 03 Nov 2018, 11:36; edited 27 times in total
Post 09 Oct 2015, 06:27
View user's profile Send private message Reply with quote
SergeASM



Joined: 13 Nov 2015
Posts: 21
In the file Console.asm I see "Copyright © 2013-2015, Nick Kouvaris". Is this the same Nick Kouvaris, which did flash games on lightforce.freestuff.gr?

Serge
Post 20 Nov 2015, 10:21
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1256
Location: In a West End town
Hi SergeASM,

Yes that's me, nice of you to ask.
Post 20 Nov 2015, 11:34
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1256
Location: In a West End town
A user-defined function has its parameters set by the user. Variables defined
within a user-defined function are local variables. The return value must be
an integer.

Code:
    sub addition(a,b)    ! function declaration

        local sum        ! local variable declaration

        sum = a+b

        rets sum         ! return value

    ends                 ! function end


    input "Enter number 1:",a
    input "Enter number 2:",b

    sum = addition(a,b)  ! function call

    print "Output:",sum
    pause
    


Last edited by Picnic on 03 Nov 2018, 11:35; edited 14 times in total
Post 11 May 2016, 11:08
View user's profile Send private message Reply with quote
redrum88



Joined: 30 Mar 2016
Posts: 5
Very nice, thanks!
Post 19 May 2016, 00:25
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1256
Location: In a West End town
A tiny set of UDP network functions is available to send and receive messages
using a connectionless UDP socket. When such a socket is created, all incoming
UDP messages are placed in the waiting stack (queue) and accessed according
to the first-in first-out (FIFO) principle.

Code:
    ! create UDP socket
    ! n=open(port)                --> int,V0

    ! send data through socket     
    ! n=send(ip$,port,data$)      --> int
  
    ! pop the queue
    ! a$=queue(0)                 --> string

    ! peek the queue
    ! a$=queue(1)                 --> string

    ! get queue info
    ! a$=queue(2)                 --> string [IP PORT LENGTH TIME]
        
    ! close connection
    ! n=close()                   --> int
    


Last edited by Picnic on 09 Sep 2018, 15:29; edited 25 times in total
Post 14 Jun 2016, 10:08
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1256
Location: In a West End town
I/O operations in Hobby Basic.

Code:
    ! file path$,a$,0          save string as text file
    ! file path$,a$,1          load text file to string
    ! file path$,a$,2          append string to end of file
    ! file path$,array[],0     save array as binary file
    ! file path$,array[],1     load binary file to array
    ! file path$,array[],2     append data to end of file
    ! file path$,0,0           create empty file
    ! file URL$,0,1            download URL
    ! file URL$,0,2            download URL w/o feedback
    ! file path$,0,3           delete file
    


Code:
    input "Write some text:",a$

    ! save string as text file
    path$=path(1)+"\a.txt"
    file path$,a$,0

    ! print file size
    print path$," ",size(path$)," bytes"
    pause
    


Code:
    ! create a com executable (16 byte DOS demo)
    dim a[4]=0x10CD13B0,0xC81107C4,0x40FBE2AA,0x94E1F8E2
    file "a.com",a[],0
    end
    


Last edited by Picnic on 03 Nov 2018, 11:30; edited 29 times in total
Post 07 Aug 2016, 09:10
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1256
Location: In a West End town
I uploaded a new version 0.7 with many small improvments and bug fixes. I tried the interpreter with success in Windows XP/7/8 32/64 bit, Wine (Linux). I removed the Win32 Console Library source code from inside the zip. It was an old version which was last updated 3 years ago. Hobby Basic is now using a newer version.


Last edited by Picnic on 03 Nov 2018, 11:37; edited 5 times in total
Post 21 Oct 2016, 08:41
View user's profile Send private message Reply with quote
filox



Joined: 13 Feb 2013
Posts: 10
Sorry but where i can find sources of Hobbybasic?
Post 21 Oct 2016, 11:52
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.