Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
Offtopic / Re: ProBoards
« Last post by John on 14. August 2017, 02:43:25 »
Besides the ads ProBoards floods you with, they put your PC to its knees draining your cookie file.
22
Offtopic / Re: ProBoards
« Last post by ZXDunny on 14. August 2017, 01:14:01 »
I used my adblocker to block it. Worked a treat.
23
Code and examples / Re: XML Parser
« Last post by John on 13. August 2017, 10:33:01 »
Here is an example of transforming the QuickBooks Online Apps Directory to a simple table list using the Script BASIC application proxy server.

Code: [Select]
' QBO Apps List

IMPORT cgi.bas
IMPORT curl.bas

ch = curl::init()
curl::option(ch,"URL","https://appcenter.intuit.com/allapps")
apps_html = curl::perform(ch)
curl::finish(ch)

cgi::Header 200,"text/html"
cgi::FinishHeader

PRINT """
<html>
<body>
<table>
<center><h1>QBO Apps Listing</h1></center>
<table style="width:100%">
  <tr>
    <th>App Name</th>
    <th>Vendor</th>
    <th>Description</th>
  </tr>
"""

SPLITA apps_html BY "<!-- this is for SEO crawlers -->" TO apps_array

FOR x = 0 TO UBOUND(apps_array)
  IF apps_array[x] LIKE """*<div class="bigappcard-display-name">*</div>*<div class="bigappcard-vendor-name">*</div>*<div class="bigappcard-tagline">*</div>*""" THEN
    PRINT "  <tr>\n"
    PRINT "    <td>",TRIM(joker(2)),"</td>\n"
    PRINT "    <td>",MID(TRIM(joker(4)),4),"</td>\n"
    PRINT "    <td>",TRIM(joker(6)),"</td>\n"
    PRINT "  </tr>\n"
  END IF
NEXT
PRINT """
</table>
</body>
</html>
"""


24
Offtopic / ProBoards
« Last post by B+ on 12. August 2017, 18:34:28 »
Literally in your face for using an ad blocker!

http://qb64.freeforums.net/thread/66/
(Dang! you have to be a member there too for attached materials.)

Is that what a pro should do?
25
yeah
they dont like lbb because is better than jb/lb
26
General questions and discussions / Re: Can you write a program for this Interpreter?
« Last post by B+ on 07. August 2017, 14:41:45 »
Aha ..ok  :)
yes LBB is far better than jb/lb and it is faster
advantage you can run any program from jb/lb in LBB

Yep! it is a great advantage unless you want to share your experience at JB forum.  ::)
27
Aha ..ok  :)
yes LBB is far better than jb/lb and it is faster
advantage you can run any program from jb/lb in LBB
28
General questions and discussions / Re: Can you write a program for this Interpreter?
« Last post by B+ on 07. August 2017, 13:57:17 »
;-))  Probably need to copy save some examples or write a program to be able to run anything.

The files looked for end with *BNB.txt

Attached is a bunch of my test files in zip. Examples until you can figure out how to write your own.

As you can see from screen shot all three of these Windows have a File menu! Load a file for the B interpreter from the running B interpreter program, the one with biggest print.

PS Hey! First time I tried LBB in couple of years, worked right out of the box! :)

PPS LBB lists Edit menu first and THEN Files menu, probably because Edit is built in when use a TextEdit control.

PPPS I was going to say my .bas extension name is registered for SmallBASIC so I write .txt Just Basic program files but you did figure that out because you got the B Interpreter loaded in LBB.
29
hi Mark
for testing i use LBB
well i agree JB is better than qb64 sdl-consoler
but i get only this:
30
General questions and discussions / Re: Can you write a program for this Interpreter?
« Last post by B+ on 07. August 2017, 05:45:26 »
JB is nice, with texteditor in GUI, I don't have to outsource to edit a program file, nice File Dialog too (compared to QB64).
Now for first time (for me) a variables table to store names and values. 275 lines or less interpreter with no eval function, easy as eating pie to add functions.

Code: [Select]
'B Interpreter v2.txt for JB (B+=MGA) 2017-08-06

global nCodeLines, nVariables, maxVariables, err$
nVariables = 0
maxVariables = 100
dim v$(maxVariables, 1)
fname$ = "untitled BNB.txt"

    '  Mainwin is output
    'probably should setup an output graphics window for color drawing and printing

    WindowWidth = 800
    WindowHeight = 675

    statictext #main.fname, "Untitled BNB.txt", 5, 5, 780, 50
    texteditor #main.te, 5, 61, 760, 540
    menu #main, "&File", "&New", [fileNew],"&Load", [fileLoad], "&Save", [fileSave], "save &As", [fileAsSave], "e&Xit", [quit]
    menu #main, "&Run","&Run",[Run]
    open "B Interpreter" for window as #main
    #main, "trapclose [quit]"
    #main, "font arial 10 20"

    wait

[fileNew]
    ttl$ = "New *BNB.txt file base name";chr$(13)
    prom$ = ttl$ + "Please enter a base name, BNB.txt will be added to it."
    prompt prom$; base$
    if base$ <> "" then fname$ = base$ + " BNB.txt" else fname$ = "untitled BNB.txt"
    #main.fname, fname$
wait

[fileLoad]
    filedialog "test", "*BNB.TXT", fname$
    if fname$ <> "" and right$(upper$(fname$), 7) = "BNB.TXT" then
        open fname$ for input as #1
        ' this next line is a total surprise to me!!!
        #main.te "!contents #1"
        close #1
    else
        fname$ = "untitled BNB.txt"
    end if
    #main.fname, fname$
wait

[fileSave]
    'save current list to file
    #main.te "!contents? txt$"
    open fname$ for output as #1
    print #1, txt$
    close #1
wait

[fileAsSave]
    ttl$ = "Another *BNB.txt file base name";chr$(13)
    prompt ttl$+"Please enter a base name, BNB.txt will be added to it.";base$
    if base$ <> "" then
        fname$ = base$ + " BNB.txt"
        #main.te "!contents? txt$"
        open fname$ for output as #1
        print #1, txt$
        close #1
    end if
    #main.fname, fname$
wait

[Run]
    'nCodeLines is global for the executor
    #main.te, "!lines nCodeLines"
    if nCodeLines > 0 then
        redim program$(nCodeLines)
        nVariables = 0 : err$ = ""
        cls
        redim v$(maxVariables, 1)
        for i = 1 to nCodeLines
            #main.te, "!line ";i;" codeLine$"
            program$(i) = codeLine$
        next
        call executor
    end if
wait

[quit]
    close #main
    end

sub executor
for i = 1 to nCodeLines
    scan
    cmd$ = upper$(word$(program$(i), 1))
    select case cmd$
        case "V"    'set VariableName Number or SET VariableName Function
            var$ = word$(program$(i), 2)
            if isVariable(var$) then
                fn$ = upper$(word$(program$(i), 3))
                p1$ = getValue$(word$(program$(i), 4))
                p2$ = getValue$(word$(program$(i), 5))
                p3$ = getValue$(word$(program$(i), 6))
                p4$ = getValue$(word$(program$(i), 7))
                p5$ = getValue$(word$(program$(i), 8))
                p6$ = getValue$(word$(program$(i), 9))
                'notice p1$;" ";p2$
                select case fn$
                    'Binary Operations
                    case "@" : val$ = p1$ '< just set a varaible to a value or variable
                    case "+" : val$ = str$(val(p1$) + val(p2$))
                    case "-" : val$ = str$(val(p1$) - val(p2$))
                    case "*" : val$ = str$(val(p1$) * val(p2$))
                    case "/" : val$ = str$(val(p1$) / val(p2$))
                    case "^" : val$ = str$(val(p1$) ^ val(p2$))
                    case "%" : val$ = str$(val(p1$) mod val(p2$))

                    'number comapares dont forget #
                    case "#=" : val$ = str$(val(p1$) = val(p2$))
                    case "#<" : val$ = str$(val(p1$) < val(p2$))
                    case "#>" : val$ = str$(val(p1$) > val(p2$))
                    case "#<=" : val$ = str$(val(p1$) <= val(p2$))
                    case "#>=" : val$ = str$(val(p1$) >= val(p2$))
                    case "#<>" : val$ = str$(val(p1$) <> val(p2$))

                    'string compares dont forget $
                    case "$=" : val$ = str$(p1$ = p2$)
                    case "$<" : val$ = str$(p1$ < p2$)
                    case "$>" : val$ = str$(p1$ > p2$)
                    case "$<=" : val$ = str$(p1$ <= p2$)
                    case "$>=" : val$ = str$(p1$ >= p2$)
                    case "$<>" : val$ = str$(p1$ <> p2$)

                    'more number 0 and -1 for Boolean Builds
                    case "AND" : if val(p1$) <> 0 and val(p2$) <> 0 then val$ = "1" else val$ = "0"
                    case "OR" : if val(p1$) <> 0 or val(p2$) <> 0 then val$ = "1" else val$ = "0"
                    case "NOT" : val$ = str$(NOT(val(p1$)))

                    'STRING STUFF

                    'set a varaible to some spaces
                    case "SPACE" : val$ = space$(val(p1$))

                    'set a variable to a string with spaces in it
                    'LS or ls stands for long string (string with spaces)
                    'LS reads next line of code between {My text inside brackets}
                    'and assigns it the the variable name on LS line.
                    case "LS" : i = i + 1
                        val$ = word$(program$(i), 2, "{")
                        val$ = word$(val$, 1, "}")
                    case "MID1" : val$ = mid$(p1$, val(p2$))
                    case "MID2" : val$ = mid$(p1$, val(p2$), val(p3$))
                    case "LEN"  : val$ = str$(len(p1$))
                    case "INPUT" : input "Enter > ";val$

                    'NUMBER STUFF

                    case "INT" : val$ = str$(int(val(p1$)))
                    case "RND" : val$ = str$(RND(0))


                end select
                call dVariable var$, val$
            else
                notice "Line ";i;" variable ";var$;" is improper name."
            end if

        'Output p is short for print, 3 ways to end
        case "P" : print getValue$(word$(program$(i), 2))
        case "P;" : print getValue$(word$(program$(i), 2));
        case "P," : print getValue$(word$(program$(i), 2)),

        'Decision branching IF... [ELSE]... FI < need one word to end block
        'FI command just marks end of IF block
        case "IF" : if getValue$(word$(program$(i), 2)) = "0" then call findi i
            if err$ <> "" then exit for
        case "ELSE" : call findi i : if err$ <> "" then exit for

        'Loop structure DO... EXIT (only way out except END)... LOOP
        'DO just marks beginning of LOOP for LOOP command
        case "LOOP" : loopCnt = -1 'count the bracket we're on
            i = i - 1   'move the code pointer back a char
            while loopCnt <> 0
                'count nested loops till we fine the matching one
                if upper$(word$(program$(i), 1)) = "LOOP" then loopCnt = loopCnt - 1
                if upper$(word$(program$(i), 1)) = "DO" then loopCnt = loopCnt + 1
                i = i - 1 'search backwards
            wend
            i = i + 1
        case "EXIT" : loopCnt = 1 'count the bracket we're on
            i = i + 1 'move the code pointer to the next char
            while loopCnt <> 0
                'count nested loops till we find the matching one
                if upper$(word$(program$(i), 1)) = "LOOP" then loopCnt = loopCnt - 1
                if upper$(word$(program$(i), 1)) = "DO" then loopCnt = loopCnt + 1
                i = i + 1 'search forward
            WEND
            i = i - 1

        case "END" : exit for
        case "CLS" : cls
        case "LOCATE" : p1$ = getValue$(word$(program$(i), 2))
            p2$ = getValue$(word$(program$(i), 3))
            locate val(p1$), val(p2$)
        case "PAUSE" : p1$ = getValue$(word$(program$(i), 2))
            call pause val(p1$)

    end select
next
print : print "Variables Table:"
for j = 1 to nVariables
    print v$(j, 0);" = ";v$(j, 1)
next
end sub

'need a way to tell a variable from a string
function isVariable(test$)
    isVariable = 0 : ca = asc(left$(upper$(test$), 1))
    'notice "isVar ";ca;" ";right$(test$, 1)
    if 64 < ca and ca < 91 then
        if right$(test$, 1) = "#" or right$(test$, 1) = "$" then
            isVariable = 1
        end if
    end if
end function


'add variable and value or edit variable value
sub dVariable variable$, value$
    if isVariable(variable$) then  'check if variable name OK
        if nVariables > 0 then
            for i = 1 to nVariables
                if variable$ = v$(i, 0) then flag = 1 : v$(i, 1) = value$ : exit for
            next
        end if
        if not(flag) then
            nVariables = nVariables + 1
            v$(nVariables, 0) = variable$ : v$(nVariables, 1) = value$
        end if
    end if
end sub

function getValue$(test$)  'if a varaible name return the value else return test$
    if isVariable(test$) then 'check if test$ is a variable name
        if nVariables > 0 then
            getValue$ = ""
            for i = 1 to nVariables
                if test$ = v$(i, 0) then getValue$ = v$(i, 1) : exit for
            next
        end if
    else
        getValue$ = test$
    end if
end function

sub findi byref i
    cnt = 1 : saveI = i
    for j = i + 1 to nCodeLines
        fw$ = upper$(word$(program$(j), 1))
        if fw$ = "FI" then
            cnt = cnt - 1
            if cnt = 0 then i = j  : exit sub
        else
            if fw$ = "IF" then
                cnt = cnt + 1
            else
                if fw$ = "ELSE" and cnt = 1 then i = j : exit sub
            end if
        end if
    next
    err$ = "Could not find FI for line ";saveI
    notice err$
end sub

sub pause mil   'tsh version has scan built-in
    t0 = time$("ms")
    while time$("ms") < t0 + mil : scan : wend
end sub

Pages: 1 2 [3] 4 5 ... 10