flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Examples and Tutorials > Hobby Basic

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



Joined: 01 Nov 2010
Posts: 16
file not found/not there ... HELP
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: 1179
Location: Athens
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 Visit poster's website Reply with quote
MajorDill



Joined: 01 Nov 2010
Posts: 16
files found
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: 1179
Location: Athens
Hobby Basic is a small, BASIC-like interpreter for Windows
Hello,

Hobby Basic is an interpreter of a small programming language for the Windows console.
It features a simple syntax in the style of BASIC.
It supports UTF-8 unicode characters, it handles keyboard, mouse, cursor.
It is written in 32-bit Assembly and developed in FASM.
It is suitable for writing simple console programs and demos.
HB is written from scratch, it is NOT a modification to an existing language.


Image


* BASIC commands supported (rem, print, input, goto, gosub, return, break, end, if.. then..else, for.. next, while.. endw, do.. until)
* Operators (=, <, >, <=, >=, <>, +, -, *, /, %, Logical: AND, OR, Bitwise: &, |, ^, <<, >>)
* Special console commands (at, cls, color, cursor, erase, inkey, invert, locate, mouse, paint, peek, copy, paste, screen, scroll, wait, file, exec).
* Functions (chr, hex, bin, spc, pow, rnd, abs, not, key, cell, tick, time, alert).
* String Functions (left, right, mid, val, asc, len, str, pad, instr, upper, lower, path).
* 32-Bit data types (UTF-8 strings, signed integer variables, 2D dimensional arrays).
* Keyboard and Mouse supported, labels instead of line numbering.
* Unicode UTF-8 encoding support.

DOWNLOAD


Last edited by Picnic on 22 Apr 2017, 08:55; edited 36 times in total
Post 31 Jul 2015, 06:16
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 392
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: 392
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: 1179
Location: Athens
Hello World
^^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
    end



Image



Drawing text is easy with Hobby Basic.

Code:

   screen 80,25

    cls 
    for y=0 to 24 
        for x=0 to 79 
            pen (x+y)/16 
            at x,y,'A' 
        next x 
    next y 
    end 



Image


Last edited by Picnic on 11 Apr 2017, 08:13; edited 14 times in total
Post 02 Aug 2015, 11:15
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1179
Location: Athens
Arrays
Update 11/4/2017

Array operations in Hobby Basic.

Code:

  dim a[5]=10,20,30,40,50

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




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 "value of a[",x,",",y,"] is ",a[x,y]
      next x
  next y




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"

  for i=0 to size(a$[])-1
      print "a$[",i,"] = ",a$[i]
  next i




Last edited by Picnic on 11 Apr 2017, 10:55; edited 13 times in total
Post 12 Aug 2015, 09:43
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 392
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: 1179
Location: Athens
Hobby Basic Examples
^^I feel it's early for that now. The interpreter is far for being complete. Surely i might do that but in later time.


Last edited by Picnic on 27 Apr 2016, 11:19; edited 6 times in total
Post 15 Aug 2015, 22:13
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1179
Location: Athens
UTF-8 encoding greek characters
Update 11/4/2017


Code:

    rem  UTF8 Greek characters

    ΤΥΠΩΣΕ fix PRINT

    CLS
    ΤΥΠΩΣΕ "---Μάντεψε τον αριθμό (-1 τέλος)---"
    INPUT "Δώσε μέγιστη τιμή (1-10000 π.χ. 100):",R
    M = RND(R)+1
    N = 0
    ΕΤΙΚΕΤΑ#
    INPUT "Μάντεψε τον αριθμό:",G
    IF G < 0 THEN END
    N = N + 1
    IF G < M THEN ΤΥΠΩΣΕ "Είναι μεγαλύτερος"
    IF G > M THEN ΤΥΠΩΣΕ "Είναι μικρότερος"
    IF G <> M THEN GOTO ΕΤΙΚΕΤΑ
    ΤΥΠΩΣΕ "Το βρήκες σε "N" προσπάθειες."
    END



Image


Last edited by Picnic on 11 Apr 2017, 10:56; edited 11 times in total
Post 03 Sep 2015, 14:45
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1179
Location: Athens
Labels
I made some changes concerning the labels.

Old form

Code:
play:


New form

Code:
play#



Now, with the character : more code can be written in a single line.
Although this feature is not fully supported yet, here is a single line example.


Code:
cls : title "Television" : for i=1 to 9 : color i,-1 : paint i*8-8,0,8,25," ",1 : next i : inkey : end



Note about the labels, a label can be placed anywhere inside code.

Code:

gosub a:end b#return a#gosub b:return




The name of an array and the name of a variable are separate names for HB.

Code:

n=100 
dim n[3]=10,20,30 
print n 
print n[0]




The size of an array can change dynamically calling the dim command again.

Code:

dim n[5]=1,2,3,4,5 
dim n[10
print size(n[]) 




A function can have a function as a parameter.

Code:

for i=0 to 99
    print "0x",hex(abs(-rnd(1024)));
next i




Last edited by Picnic on 26 Nov 2016, 11:10; edited 9 times in total
Post 09 Oct 2015, 06:27
View user's profile Send private message Visit poster's website Reply with quote
SergeASM



Joined: 13 Nov 2015
Posts: 16
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: 1179
Location: Athens
Hi SergeASM,

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



Joined: 05 May 2007
Posts: 1179
Location: Athens
fix directive
Here are some new features.

Commenting out code is done by putting ` at the start of a line.

Code:


    ` commenting out code is done 
    ` by putting ` at the start of a line 




The \ character can be used to continue code in the next line.

Code:

dim myarr[10]=\
    1,2,3,4,5,\
    6,7,8,9,10




This is a valid line.

Code:

    for\
        i=1\
        to\
        15
        locate\
        i,\
        i
        color\
        0,\
        i
        p
        p fix print "Hello World!"
    next\
    i:end




The fix directive can be used to replace a signle word in source code before program execution.

Code:

    repeat fix do

    repeat
        wait 1
    until key(27)<>0




It can also be used to replace an expression (utf-8 encoding supported).
The following program displays the mouse coordinates on the console title bar.

Code:

    GetXY fix mouse:x=VAR0:y=VAR1
    DisplayCoords fix do:GetXY:title x,",",y:wait 1:until key(27)<>0:end

    DisplayCoords




Last edited by Picnic on 28 Oct 2016, 20:24; edited 3 times in total
Post 11 May 2016, 11:08
View user's profile Send private message Visit poster's website 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: 1179
Location: Athens
Strings
Update 11/4/2017

String manipulation in HB.

Code:

  ! left(string$,length)
  ! right(string$,length)
  ! mid(string$,start,length)
  ! cmp(string$,string$)
  ! instr(string$,string$,[start])
  ! pad(string$,char,length)
  ! upper(string$)
  ! lower(string$)
  ! trim(string$)
  ! val(string$)
  ! asc(string$)
  ! len(string$)
  ! str(number)
  ! base(number,radix)




Code:

  a$="Good "
  b$="Morning Evening Afternoon"
  print a$,left(b$,7)
  print a$,mid(b$,9,8)
  print a$,right(b$,9)




Code:

  input "Type a word:",a$
  print
  for i=1 to len(a$)
      b$=mid(a$,i,1)
      print b$," ",asc(b$)
      wait 25
  next i




Code:

  a$="1024 8"
  b$=str(val(left(a$,4))/val(right(a$,1)))
  print b$




Code:

  a$="ABCDEBXYZ"
  b$="B"
  print instr(a$,b$)    ! prints 2
  print instr(a$,b$,4)  ! prints 6




Code:

do
    input "Type ΕΧΙΤ:",a$
until cmp(upper(a$),"EXIT")=1




Last edited by Picnic on 11 Apr 2017, 12:09; edited 9 times in total
Post 14 Jun 2016, 10:08
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1179
Location: Athens
I/O operations
Update 11/4/2017

Here are some new features.

Commenting out code symbol ` replaced by !

Code:

! commenting out code is done  
! by putting ! at the start of a line




Anonymous labels.

Code:

 @@#

    !  Two at signs @@ followed by # create an anonymous label.
    !  goto @b  (backward jump)
    !  goto @f  (forward jump)

 goto @b





A file command is now available allowing simple I/O operations.

Code:

  file path,string$,0     ! save string as text file
  file path,string$,1     ! load text file to string
  file path,string$,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 path,0,2           ! delete file




Code:

  ! write text to file
  for i=1 to 5
      a$=a$+"Text line "+str(i)+chr(13)+chr(10)
  next i
  file "a.txt",a$,0




Code:

  ! load text from file
  file "art.txt",a$,1
  if VAR0<0 then a$="missing art.txt"
  color 12,0
  print a$




Code:

  ! create a com executable (needs DOSBox)
  dim a[4]=0x10CD13B0,0xC81107C4,0x40FBE2AA,0x94E1F8E2
  file "a.com",a[],0




Code:

  ! print public ip
  file "http://icanhazip.com/index.php",a$,1
  if VAR0<0 then a$="load error"
  print a$




See who is online in fasm board (broken).

Code:

    screen 80,50:cls:n=0:k=0:b$=''
    file 'http://tinyurl.com/zm66oye',b$,1
    if VAR0<0 then print 'load error':end
    print 'Who Is Online':print
    i=instr(b$,'There')
    j=instr(b$,'This data')
    a$=mid(b$,i,j-i-20)
    L fix chr(13)+chr(10)
    S fix chr(32)
    T fix chr(9)
    for i=1 to len(a$)
@@if cmp(mid(a$,i,4),S+L+S)=1 then i=i+4:goto @b
        if cmp(mid(a$,i,3),L+T)=1 then i=i+2:goto @b
        if cmp(mid(a$,i,6),'&nbsp;')=1 then i=i+6:goto @b
        k=asc(mid(a$,i,1)):if k=60 or k=62 then n=n^1
        if n=0 and k<>62 then print chr(k),
    next i
    end



Image



This code creates a 16 color drawing pad in console window which can load or save an image preserving the color attributes.

Code:

    rem  16 Colors Drawing Pad for Hobby Basic

    PrintXY fix  lx=x:ly=y:a$=STR(x)+','+STR(y)+' ':color 8,15:at 2,6,a$
    PrintChar fix  color bg,fg:locate x,y:at x,y,CHR(c)
    GetMouse fix  mouse:x=VAR0:y=VAR1:btn=VAR2:wait 1
    DelChar fix  color 0,0:at x,y,' '

    cols=90
    rows=35
    screen cols,rows
    cls

    dim a[200]
    dim m[cols,rows]
    dim e[cols,rows]
    p=0:i=0:c=0

    for i=0x20 to 0x200
        at 0,0,CHR(i)
        c=CELL(0,0)
        if c<>63 and p<200
            a[p]=c
            p=p+1
        endif
    next i

    for i=0x2500 to 0x26EF
        at 0,0,CHR(i)
        c=CELL(0,0)
        if c<>63 and p<200
            a[p]=c
            p=p+1
        endif
    next i

    title p," symbols loaded"
    cls

    for i=0 to p-1
        print CHR(a[i]),
        if i%8=0 then print
    next i

    copy 0,0,8,rows:cls
    paste cols-9,0,8,rows
    color 8,15
    paint 0,0,8,rows,' ',1
    paint cols-10,0,10,rows,-1,1
    at 1,0," Save"
    at 1,2," Load"
    at 1,4," Clear"
    at 1,6," ----"
    color 7,15
    at 1,8,"  FG  "
    color 0,15
    at 1,10,"  BG  "
    cursor 1,100
    locate 8,0
    erase 0,8,1,'>',0

    for i=0 to 7
        color ii
        paint 1,i*2+12,3,2,' ',1
    next i

    for i=0 to 7
        color i+8,i+8
        paint 4,i*2+12,3,2,' ',1
    next i

    lx=0:ly=0:bg=0:fg=7:c=32:v=0:cx=0:cy=0:j=0:r=0

    do:GetMouse

        if x>7 and x<cols-10

            if lx<>x or ly<>y then PrintXY

            if btn=1
                PrintChar
                do:GetMouse
                    if x>7 and x<cols-10 and (lx<>x or ly<>y)
                        PrintChar:PrintXY
                    endif
                until btn=-1
            elseif btn=2
                DelChar
                do:GetMouse
                    if x>7 and x<cols-10 and (lx<>x or ly<>y)
                        DelChar:PrintXY
                    endif
                until btn=-1
            endif

        elseif x<8

            if btn=1

                if y=0
                    for i=8 to cols-11
                        for j=0 to rows-1
                            peek i,j
                            m[i,j]=(((VAR2<<8)|VAR1)<<16)|VAR0
                        next j
                    next i
                    file "a.dat",m[],0
                    if VAR0<0
                        title "save error"
                    else
                        title "save ok"
                    endif

                elseif y=2
                    file "a.dat",e[],1
                    if VAR0<0
                        title "load error"
                    else
                        title "load ok"
                    endif
                    for i=8 to cols-11
                        for j=0 to rows-1
                            r=e[i,j]
                            color (r>>16)&0xF,r>>24
                            at i,j,CHR(r&0xFFFF)
                        next j
                    next i

                elseif y=4
                    color 0,7
                    paint 8,0,cols-18,rows,' ',1
                    title "clear ok"

                elseif y=8
                    v=0
                    erase 0,8,1,'>',0
                    erase 0,10,1,' ',0

                elseif y=10
                    v=1
                    erase 0,10,1,'>',0
                    erase 0,8,1,' ',0

                elseif y>11 and y<rows-2
                    peek x,y
                    if v=0
                        fg=VAR2
                        color fg,-1
                        paint 1,8,6,1,-1,1
                    elseif v=1
                        bg=VAR1
                        color bg,-1
                        paint 1,10,6,1,-1,1
                    endif
                endif
            endif

        elseif x>cols-10

            if btn=1
                if x<>cx or y<>cy
                    color 8,15
                    erase cx,cy,1,-1,1
                    c=CELL(x,y)
                    at 3,rows-1,CHR(c)
                    color 8,11
                    erase x,y,1,-1,1
                    title "U+",c
                    cx=x:cy=y
                endif
            endif

        endif

    until KEY(27)<>0
    end




Image


Last edited by Picnic on 11 Apr 2017, 12:33; edited 18 times in total
Post 07 Aug 2016, 09:10
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1179
Location: Athens
I uploaded a new version 0.79 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 06 Dec 2016, 20:11; edited 4 times in total
Post 21 Oct 2016, 08:41
View user's profile Send private message Visit poster's website 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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.