flat assembler
Message board for the users of flat assembler.

flat assembler > Examples and Tutorials > Hobby Basic

Goto page Previous  1, 2, 3
Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15904
Location: SDSS J140821.67+025733.2
filox wrote:
Sorry but where i can find sources of Hobbybasic?
Have a look at the first post in this thread.
Post 21 Oct 2016, 12:13
View user's profile Send private message Visit poster's website Reply with quote
system error



Joined: 01 Sep 2013
Posts: 671
This is good. Keep it coming, bro!
Post 22 Oct 2016, 13:32
View user's profile Send private message Reply with quote
filox



Joined: 13 Feb 2013
Posts: 10
revolution wrote:
filox wrote:
Sorry but where i can find sources of Hobbybasic?
Have a look at the first post in this thread.


No source, only EXE and Demo.bas
Post 26 Oct 2016, 12:24
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 7395
Location: ˛                              ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣ Posts: 6699
hi filox,
you could try pm picnic for source etc
Post 26 Oct 2016, 12:36
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1246
Location: Icarian Sea
Hi filox, the source is not available, at least not yet. Hobby Basic has still some way to go. I want to extend the command list, find methods to make the intepreter faster, add features like user procedures with parameters and local variables and some other ideas i have. This is done somewhat slowly, the only days i can steal some time to work are the weekends.
Post 26 Oct 2016, 13:37
View user's profile Send private message Reply with quote
filox



Joined: 13 Feb 2013
Posts: 10
Picnic wrote:
Hi filox, the source is not available, at least not yet. Hobby Basic has still some way to go. I want to extend the command list, find methods to make the intepreter faster, add features like user procedures with parameters and local variables and some other ideas i have. This is done somewhat slowly, the only days i can steal some time to work are the weekends.


Hi picnic, if u can share code with us, we can help you possibly to improve it faster and i'm interested in it for educational scope Very Happy
Post 18 Nov 2016, 13:19
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1246
Location: Icarian Sea
Quote:
...and i'm interested in it for educational scope

Take a look at MINI-BASIC for fasm. It's a piece of code available for modifications.
Post 21 Nov 2016, 15:50
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1246
Location: Icarian Sea
I have uploaded a new version with bug fixes and various internal tweaking.

A string variable is identified by the symbol $ at the end of a variable name.
Concatenation uses the + addition symbol to add literal or variable 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 08 Jan 2018, 07:36; edited 15 times in total
Post 21 Dec 2016, 12:34
View user's profile Send private message Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 166
Location: Madrid - Spain
Hello, it is very interesting. I was very fond of qbasic. I'd just say that it would be nice to see your page in English, Greek is a bit hard for me Smile
Post 21 Dec 2016, 13:20
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1246
Location: Icarian Sea
It's been some time since my last post about HB. All this time there were some bug fixes and various internal tweaking, but not a major update.
Hobby Basic now includes an embedded ANSI file loader that recognizes standard DOS ANSI.SYS escape codes for colours and cursor movement.
Having a console library already written (the one that HB is using as backend), it took me a few hours of work to accomplish it.


Loading an ANSI image is simply a command.
Code:
    ! n is optional. It controls the drawing speed.
    ! n=0 unlimited (default)
    ! n=1 slow...100 fast


    path$ = "ART\APPLE.ANS"

    screen 80,25
    cls

    if SIZE(path$)<>-1   ! check if file exists
        ansi 0,path$
        inkey
    endif

    end
    

Image




Another example, slightly more advanced. An ANSI text file viewer.
Code:
  
    rem  View multiple ANSI coded text files in folder
    rem  Hobby Basic Sample

    s=20                               ! drawing speed
    d=2000000                          ! delay between images
    auto=1                             ! autoplay slideshow
    count=0                            ! valid files found
    max=250                            ! max files in folder
    dim ext$[2] = ".ans" , ".asc"      ! valid file extensions
    path$=PATH(0)+"\ART\"              ! path to ART folder
    cmd$="DIR "+path$+" /b"
    exec cmd$,dir$
    screen 80,30
    cursor 0,0

    forever#

    for n=1 to max
        a$=READLN(n,dir$)
        if V0=-1 then break
        filename$=path$+a$
        if SIZE(filename$)<>-1           ! check if file exists
            if check_ext(filename$)=1
                count=count+1
                title filename$
                color 0,7:cls
                ansi s,filename$
                if KEY(27) then end
                if auto=1 then wait d else inkey
            endif
        endif
    next n

    if count=0 then alert "no files found":end

    goto forever



rem  Check for valid file extension
sub check_ext(path$)

    local i

    for i=0 to SIZE(ext$[])-1
        if COMP(LCASE(RIGHT(path$,4)),ext$[i])=1 then rets 1
    next i

    rets 0
ends
    
Post 28 May 2018, 13:49
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1246
Location: Icarian Sea
A Peer-to-peer (P2P) UDP drawing program written in Hobby Basic.
To test it with 1 computer, swap ports between the 2 HB instances.
Left click to draw, right click opens the color picker, spacebar to clear current screen.
Refer to readme.txt for information about the UDP network functions.

Code:
    rem  P2P.bas
    rem  Peer-to-peer (P2P) UDP drawing program
    rem  Replace localhost with Ipv4 address
    rem  Hobby Basic Sample

    MY_PORT=1024
    REMOTE_PORT=1025

    IP$="localhost"   ! remote ip

    ! create UDP socket
    n=OPEN(MY_PORT)
    if n=-1 then trace "error ",V0:end

    COLS=80
    ROWS=40
    screen COLS,ROWS
    title "Peer-to-peer (P2P) UDP drawing program"
    cursor 0,0
    color 0,0
    cls

    x=-1
    y=-1
    p=15

    do  ! loop until Esc

        GetMouse()
        if Button=1
            SendMouse()
            while Button<>-1
                if GetMouse()
                    SendMouse()
                endif
            endw
        elseif Button=2
            copy 0,0,COLS,ROWS
            PickColor()
            paste 0,0,COLS,ROWS
        endif

        if KEY(32)<>0 then color 0,0:cls

        CheckQueue()

    until KEY(27)<>0

    n=CLOSE()
    end


! open color picker
sub PickColor()

    local n

    for n=0 to 15
        color n,n
        paint n*3,0,3,2,0x20,1
    next n

    while 1
        GetMouse()
        if Button=1
            peek x,y
            if y<2 then p=V1
            break
        endif
    endw

ends


! handle incoming messages (if any)
sub CheckQueue()

    local x,y,n,data$="",a$[3]

    while LEN(QUEUE(1))<>0
        data$=QUEUE(0)
        if SPLIT(data$," ",a$[])>0
            x=VAL(a$[0])
            y=VAL(a$[1])
            n=VAL(a$[2])
            color n,n
            at x,y,CHR(0x20)
        endif
    endw

ends


! send mouse to remote pc
sub SendMouse()

    local n,data$

    color p,p
    at x,y,CHR(0x20)

    data$=STR(x)+" "+STR(y)+" "+STR(p)
    n=SEND(IP$,REMOTE_PORT,data$)

ends


! get mouse information
sub GetMouse()

    wait 1

    mouse
    Button=V2

    if x<>V0 or y<>V1
        x=V0
        y=V1
        rets 1
    endif

    rets 0
ends
    



I paint the knight on one of my two computers...

Image

at the same time it appears to the other.

Image
Post 16 Aug 2018, 12:48
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

< 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.