flat assembler
Message board for the users of flat assembler.
 flat assembler > Examples and Tutorials > Hobby Basic Goto page Previous  1, 2, 3  Next
Author
MajorDill

Joined: 01 Nov 2010
Posts: 16

when I click on download nothing is there. Just learning fasm and could really use these examples.

begging somebody to repost them

thankyou
26 Apr 2014, 18:04
Picnic

Joined: 05 May 2007
Posts: 1224
Location: Mikrolimano
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
26 Apr 2014, 21:40
MajorDill

Joined: 01 Nov 2010
Posts: 16

# files found

got it - thanks
28 Apr 2014, 14:01
Picnic

Joined: 05 May 2007
Posts: 1224
Location: Mikrolimano

# Hobby Basic interpreter

[Text moved to first post]

Last edited by Picnic on 27 Jun 2017, 07:43; edited 38 times in total
31 Jul 2015, 06:16
fasmnewbie

Joined: 01 Mar 2011
Posts: 510
I love this stuff. Excellent materials for beginners to learn from (although there's nothing 'beginners' with the code)
01 Aug 2015, 02:54
fasmnewbie

Joined: 01 Mar 2011
Posts: 510
01 Aug 2015, 03:10
Picnic

Joined: 05 May 2007
Posts: 1224
Location: Mikrolimano

# 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     inkey

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      inkey

Last edited by Picnic on 15 May 2018, 18:48; edited 18 times in total
02 Aug 2015, 11:15
Picnic

Joined: 05 May 2007
Posts: 1224
Location: Mikrolimano

# Arrays

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 23 Feb 2018, 15:13; edited 17 times in total
12 Aug 2015, 09:43
fasmnewbie

Joined: 01 Mar 2011
Posts: 510
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.
12 Aug 2015, 12:43
Picnic

Joined: 05 May 2007
Posts: 1224
Location: Mikrolimano

# 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
15 Aug 2015, 22:13
Picnic

Joined: 05 May 2007
Posts: 1224
Location: Mikrolimano

# Encoding UTF-8 characters

Encoding UTF-8 characters.
 Code: rem  Encoding UTF-8 characters     rem  Change the console font to Lucida Console     rem  Hobby Basic Sample     print "Euro Symbol: €."     print "English: I can eat glass and it doesn''t hurt me."     print "Greek: Μπορώ να φάω γυαλί χωρίς να πάθω τίποτα."     print "Íslenska / Icelandic: Ég get etið gler án þess að meiða mig."     print "Romanian: Pot să mănânc sticlă și ea nu mă rănește."     print "Ukrainian: Я можу їсти шкло, й воно мені не пошкодить."     print "Polish: Mogę jeść szkło, i mi nie szkodzi."     print "Czech: Mohu jíst sklo, neublíží mi."     pause

Last edited by Picnic on 23 Feb 2018, 15:14; edited 19 times in total
03 Sep 2015, 14:45
Picnic

Joined: 05 May 2007
Posts: 1224
Location: Mikrolimano

# Functions

A set of built-in functions is available. These functions are returning either
an integer value or a string pointer. A variable to store the return value
must precede the function call.
 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(n)                   --> 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     ! rnd(n)                    --> int     ! spc(n)                    --> string     ! str(n)                    --> string     ! tick(n)                   --> int     ! trim(a\$)                  --> string     ! ucase(a\$)                 --> string     ! val(a\$)                   --> int     n=val("510")/2              ! returns 255     n=asc("hello")              ! returns 104 (ASCII of "h")     n=find("abcdefg","de")      ! returns 4        a\$=chr(65)                  ! returns "A"     a\$="0x"+ucase(hex(255))     ! returns "0xFF"     a\$=right("Hello",2)         ! returns "lo"     a\$=path(0)                  ! returns HB path (e.g., "C:\HB")     print lcase("HELP Me")      ! prints "help me"     do:wait 1:until key(27)<>0  ! waits until key Esc is pressed

A user-defined function returns an integer value. A variable can be passed
(by value) as parameter to the function. A variable to store the return value
must precede the function call. Local variables which are declared inside a
function, can be used only inside that function.
 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 Mar 2018, 22:24; edited 23 times in total
09 Oct 2015, 06:27
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
20 Nov 2015, 10:21
Picnic

Joined: 05 May 2007
Posts: 1224
Location: Mikrolimano
Hi SergeASM,

Yes that's me, nice of you to ask.
20 Nov 2015, 11:34
Picnic

Joined: 05 May 2007
Posts: 1224
Location: Mikrolimano

# Labels

A label is identified by the symbol # at the end of a token. Comments inside
source code begin 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 23 Feb 2018, 15:15; edited 11 times in total
11 May 2016, 11:08
redrum88

Joined: 30 Mar 2016
Posts: 5
Very nice, thanks!
19 May 2016, 00:25
Picnic

Joined: 05 May 2007
Posts: 1224
Location: Mikrolimano

This sample creates a 16 color drawing pad in console window which can load or save images preserving the color attributes.
 Code: rem  Draw.bas     rem  16 Colors Drawing Pad     rem  Hobby Basic Sample     PrintXY  fix  oldX=X:oldY=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=V0:Y=V1:B=V2:wait 1     DelChar  fix  peek X,Y:color V1,V1:at X,Y,' '     cols=90:rows=35     screen cols,rows     color 0,7:cls     dim a[260]     dim m[72,35]     dim e[72,35]     dim s\$[100]     p=0:i=0:c=0     for i=0x20 to 0xFF         at 0,0,CHR(i)         c=CELL(0,0)         if c<>63 and p<250             a[p]=c             p=p+1         endif     next i     for i=0x2070 to 0x2BFF         at 0,0,CHR(i)         c=CELL(0,0)         if c<>63 and p<250             a[p]=c             p=p+1         endif     next i     title "Draw - ",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 0,0     locate 8,0     erase 0,8,1,'>',0     for i=0 to 7         color i, i         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     oldX=0:oldY=0:bg=0:fg=7:c=32:v=0:cx=0:cy=0:r=0     do:GetMouse         if X>7 and XX or oldY<>Y then PrintXY             if B=1                 PrintChar                 do:GetMouse                     if X>7 and XX or oldY<>Y)                         PrintChar:PrintXY                     endif                 until B=-1             elseif B=2                 DelChar                 do:GetMouse                     if X>7 and XX or oldY<>Y)                         DelChar:PrintXY                     endif                 until B=-1             endif         elseif X<8             if B=1                 if Y=0                     locate -1,-1                     oldX=V0:oldY=V1                     copy 0,0,90,35                     color 0,7:cls                     exec "dir/b",a\$                     r=0:i=0:p=0:a\$=TRIM(a\$)                     do:i=i+1:b\$=READLN(i,a\$):r=V0:b\$=TRIM(b\$)                         if r<>-1 and COMP(RIGHT(b\$,3),".hb")=1                             s\$[p]=b\$:p=p+1                         endif                     until r=-1                     print "File list":print "========="                     title -1,t\$,"Save"                     if p=0 then print p," files found!":goto @f                     for i=0 to p-1                         print i+1," ",s\$[i]                     next i                     @@# cursor 1,25                     print:input "Enter a file name to write: ",p\$:p\$=TRIM(p\$)                     cursor 0,0:paste 0,0,90,35:locate oldX,oldY:color bg,fg                     if ~COMP(RIGHT(p\$,3),".hb") then p\$=p\$+".hb"                     if LEN(p\$)>3                         grab 8,0,72,35,m[],0                         file p\$,m[],0                         if V0<0 then title "saving failed" else title p\$                     else                         title t\$                     endif                 elseif Y=2                     locate -1,-1                     oldX=V0:oldY=V1                     copy 0,0,90,35                     color 0,7:cls                     exec "dir/b",a\$                     r=0:i=0:p=0:a\$=TRIM(a\$)                     do:i=i+1:b\$=READLN(i,a\$):r=V0:b\$=TRIM(b\$)                         if r<>-1 and COMP(RIGHT(b\$,3),".hb")=1                             s\$[p]=b\$:p=p+1                         endif                     until r=-1                     print "File list":print "========="                     title -1,t\$,"Load"                     if p=0                         print p," files found!":print:pause                         while KEY(27)<>0:wait 1:endw:i=0:goto @f                     endif                     for i=0 to p-1                         print i+1," ",s\$[i]                     next i                     cursor 1,25:print:print "Enter a number from 1 to ",p,": ",                     input i:cursor 0,0                     @@# paste 0,0,90,35                     locate oldX,oldY                     color bg,fg                     if i>0 and i<=p                         p\$=s\$[i-1]                         file p\$,e[],1                         if V0<0                             title "loading failed"                         else                             grab 8,0,72,35,e[],1                             title p\$                         endif                     else                         title t\$                     endif                 elseif Y=4                     color 0,0                     paint 8,0,72,35,' ',1                     color bg,fg                     title "Draw"                 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<28                     peek X,Y                     if v=0                         fg=V2                         color fg,-1                         paint 1,8,6,1,-1,1                     else                         bg=V1                         color bg,-1                         paint 1,10,6,1,-1,1                     endif                 endif             endif         elseif X>cols-10             if B=1                 if X<>cx or Y<>cy                     color 8,15:erase cx,cy,1,-1,1                     c=CELL(X,Y):at 3,rows-2,CHR(c)                     cx=X:cy=Y:pen 11:erase cx,cy,1,-1,1                     title "Draw U+",c                 endif             endif         endif     until KEY(27)<>0     end

Last edited by Picnic on 15 May 2018, 18:49; edited 15 times in total
14 Jun 2016, 10:08
Picnic

Joined: 05 May 2007
Posts: 1224
Location: Mikrolimano

# I/O operations

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(0)+"\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 08 Jan 2018, 07:32; edited 26 times in total
07 Aug 2016, 09:10
Picnic

Joined: 05 May 2007
Posts: 1224
Location: Mikrolimano
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
21 Oct 2016, 08:41
filox

Joined: 13 Feb 2013
Posts: 10
Sorry but where i can find sources of Hobbybasic?
21 Oct 2016, 11:52
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------Blog General----------------MainDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsCompiler InternalsIDE DevelopmentOS ConstructionNon-x86 architecturesHigh Level LanguagesProgramming Language DesignProjects and IdeasExamples and Tutorials Other----------------FeedbackHeapTest Area
Goto page Previous  1, 2, 3  Next

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum