Board Logo
« Creating Your First Executable Program (.EXE) »

Welcome Guest. Please Login or Register.
Jan 16th, 2018, 3:42pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1 2 3 4  5 Notify Send Topic Print
 sticky  Author  Topic: Creating Your First Executable Program (.EXE)  (Read 4044 times)
JohnDavidson
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 4142
xx Re: Creating Your First Executable Program (.EXE)
« Reply #15 on: Sep 14th, 2008, 04:29am »

Sounds like you have hard coded the Bmp path.
Code:
bmpbutton #1.bmpbutton1, "D:\Program Files\Just BASIC v1.01\bmp\button15.bmp", [bmpbutton1Click], UL, 26, 16 

For this to work the program would have to be on the D drive in Program Files\Just BASIC v1.01\ and there would have to be a sub folder named Bmp.


Code:
bmpbutton #1.bmpbutton1, "bmp\button15.bmp", [bmpbutton1Click], UL, 26, 16 

This allows the program to run in it's install folder as long as you have provided the Bmp sub-folder and it contains the required bitmaps.

John
User IP Logged

John Davidson
e-me: johnshomeport@yahoo.com
My JB Page: http://john.jbusers.com/
Did ya Libby yet? http://lblibby.com/
carl123
Member in Training
ImageImage


member is offline

Avatar




PM


Posts: 46
xx Re: Creating Your First Executable Program (.EXE)
« Reply #16 on: Sep 18th, 2008, 06:57am »

This is how I wrote the code:

Code:
loadbmp "h", "bmp\h=xy.bmp"
loadbmp "x", "bmp\xbc.bmp"
 


The bitmaps are loaded, which are in a subfolder, as soon as the program starts and after the main window opens. I wrote it this way so that the bitmaps can be opened even if the parent folder is moved to a different partition of my pc. The bitmaps are unloaded before the close command.
User IP Logged

Welopez
Moderator
ImageImageImageImageImage


member is offline

Avatar

Never let your beliefs get in the way of learning.


PM

Gender: Male
Posts: 4407
xx Re: Creating Your First Executable Program (.EXE)
« Reply #17 on: Sep 18th, 2008, 07:11am »

Why don't you try:
Code:
loadbmp "h", "xy.bmp"
loadbmp "x", "xbc.bmp"
 

... and then put your BMP images in your project folder, the same one which contains your program. Then you will not have a problem with the path, and your images will be included with the program no matter where it is moved.

Good luck!

User IP Logged

JB 1.01
Win7 64bit, 4 GB RAM, Pentium 6200@2.13 GHz (laptop)
WinXP, 1 GB RAM, Intel N270@1.6 GHz (netbook)
shootokillme
New Member
Image


member is offline

Avatar




PM


Posts: 2
xx Re: Creating Your First Executable Program (.EXE)
« Reply #18 on: Aug 18th, 2009, 5:48pm »

guys can u help me with this? Im just new here in jbasic and im having a hard time with my homework. Please help me, I want to learn this language.

------------------------------------------------------------------------

A. To determine the number of square centimeters of tin needed to make a tin can, add the square of the radius of the can to the product of the radius and height of the can, and then multiply this sum by 6.283. Write a program that requests the radius and height of a tin can in centimeters as input and displays the number of square centimeters to make the can.
User IP Logged

Welopez
Moderator
ImageImageImageImageImage


member is offline

Avatar

Never let your beliefs get in the way of learning.


PM

Gender: Male
Posts: 4407
xx Re: Creating Your First Executable Program (.EXE)
« Reply #19 on: Aug 18th, 2009, 6:47pm »

Why don't you show us what you've done so far, shoot? Anyone can write the code for you... but then, what have you learned?

Write some code to get input from the user, for radius and height; then write the code to compute the sq/cm of tin needed? Post the code and we'll have a dozen people check it over and show you what you've done right, but might be easier another way; and what you've done wrong, if anything.

We don't like to do homework for students... it's sort of like peeking in the back of the book to find the answers. undecided

Good luck to you!

« Last Edit: Aug 18th, 2009, 6:48pm by Welopez » User IP Logged

JB 1.01
Win7 64bit, 4 GB RAM, Pentium 6200@2.13 GHz (laptop)
WinXP, 1 GB RAM, Intel N270@1.6 GHz (netbook)
jeremyhowell
Senior Member
ImageImageImageImageImage


member is offline

Avatar

A Life? Cool! Where can I download one of those from?


Homepage PM

Gender: Male
Posts: 874
xx Re: Creating Your First Executable Program (.EXE)
« Reply #20 on: Aug 18th, 2009, 7:04pm »

Yo shoot, you don't need to post the same question twice, odds are high it will be seen and answered by some one very swiftly. wink

~ Jeremy

User IP Logged

The mods and admins are not paid to help you and run this forum, so give them the respect they deserve. wink

Free Games

AMD Athlon XP 2200+ 1.81Ghz, 512mb RAM, GeForce 7600 GS, Windows XP Home Edition SP3, Just BASIC 1.01
tooanalytical
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1739
xx Re: Creating Your First Executable Program (.EXE)
« Reply #21 on: Dec 12th, 2009, 10:19pm »

Welopez often suggests using Iexpress to create installers for program packages created in Just BASIC. Here is a link to a guide for how to use Iexpress:

http://www.dreamincode.net/forums/showtopic58201.htm

The program should be easy to use. XP? Vista? users should apparantly have Iexpress on their computers. The program seems to be for uncomplicated installer creation.
User IP Logged

scwong
New Member
Image


member is offline

Avatar




PM


Posts: 9
xx Re: Creating Your First Executable Program (.EXE)
« Reply #22 on: Jan 10th, 2010, 04:19am »

Hi, I am new in justBasic. Actually, I have not done any programming for years. I wrote a program to help my son to practise addition/substraction calculation. The .bas is running alright. But, if I make the .tkn and run the file using "run *.tkn file", I got the runtime error : index: 0 is outside of collection bounds. It happens even for a two-lines program:

print "hello world"
end

I tried the fformj10.bas which comes with the software. The same thing happens.

I must overlook something or I did something silly!
Please help.
User IP Logged

Welopez
Moderator
ImageImageImageImageImage


member is offline

Avatar

Never let your beliefs get in the way of learning.


PM

Gender: Male
Posts: 4407
xx Re: Creating Your First Executable Program (.EXE)
« Reply #23 on: Jan 10th, 2010, 06:51am »

Hi there, scwong! Welcome to the world of Just Basic. So sorry, I'm getting older and my eyes are not what they used to be. My ESP has been even worse. I cannot imagine what you might have done wrong writing your code, and I cannot read your mind.

I know a lot of people are reluctant to show their work in progress, even "hello world," but it's very difficult for us to guess where you've made a mistake when we can't see what you've done. Is there any reason you are reluctant to post the code you have written? If you do so, one of our more than 4,000 users may be able to help you.

Or you might even do a forum search, looking for a topic such as "calculator clone", "a little calculator", "look alike calculator" or something along those lines. You'll find that several people have already written a program such as you are trying to create. I'm not encouraging you to "steal" what has already been done... you can look at how a properly working program is written and hopefully find where you made a wrong turn.

It does not sound as if your problem has anything to do with "creating your first executable...." More likely it is a short circuit between START and END. undecided
User IP Logged

JB 1.01
Win7 64bit, 4 GB RAM, Pentium 6200@2.13 GHz (laptop)
WinXP, 1 GB RAM, Intel N270@1.6 GHz (netbook)
Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Re: Creating Your First Executable Program (.EXE)
« Reply #24 on: Jan 10th, 2010, 08:05am »

Quote:
"run *.tkn file",


I assume you are clicking the menu at the top of the IDE. Once you click "run*.tkn file" are you presented with a list of .tkn files?

If you are and you click on one you instantly get index out of bounds error?

If so you probably need to look at where you are storing the files. Have you stored them in a protected directory like \user\di\*.tkn? Read the thread about Vista and Windows 7. Just BASIC is a lot easier to play with if it sits in its own root directory and you store .bas and .tkn files there too. Otherwise Windows kicks in its protection routines and wont let Just BASIC see or open files stored in protected areas.
User IP Logged

scwong
New Member
Image


member is offline

Avatar




PM


Posts: 9
xx Re: Creating Your First Executable Program (.EXE)
« Reply #25 on: Jan 10th, 2010, 6:25pm »

I do want to share my code just as others doing in this site. Their generous sharing of their work speeds up my learning of using justBasic in a very short time! I planned to do so after I made sure the code is alright. Also, it is sure related to 'my first exe program' because I found the problem when I tried making the program exe (I do not want my son to click through all the menu and file selection to start practice.) I posted the two lines code for simplicity because I thought it can illustrate my problem equally well. By the way, the tkn file is created without problem. I got the error when I clicking the "run *.tkn file" in IDE or run from jbrun101.exe (renamed to myprogram.exe).

Below is my code . I am sorry that I do not know how to make it in a pretty box like the others do. I will post the error log in next message because it is too long for one post.

Code:
'Paolo_maths.BAS - Maths Quiz for Paolo to practise + - x /
'Requires Just BASIC v1.0 or better

'### global variables and constants are defined here

    '(gloabl variables)
    global quizHead$, quizMid$, quizTail$, quizCursor
    global ansAt$, ansStr$, ansStart, ansLen, entryStr$
    global quizHead$, quizMid$, quizTail$
    global testType$, testLevel, itemCount
    global a,b,c,lastA, lastB, lastC
    global timeStart, errCount

    '(global constants initialization)
    global quizXStart, quizYStart, pixelMargin, quizChrHeight, quizChrWidth
    global quizFont$, boardFont$, boardXStart, boardYStart
    quizXStart = 10
    quizYStart = 695
    pixelMargin = 5
    quizChrHeight = 33
    quizChrWidth = 27
    quizFont$ = "cooper_black 33"
    boardFont$ = "arial 20 bold"
    boardXStart = 30
    boardYStart = 30


'### main program starts at here

    '(initialize global variable)
    testType$ = ""
    testLevel = 0
    quizHead$ = "(534 + 123) x (765 - "
    quizMid$ = "123"
    quizTail$ = ") = 8567"
    ansAt$ = "mid"
    itemCount = 20
    lastA=0
    lastB=0
    lastC=0

    '(no main window)
    nomainwin

    '(setup GUI interface window)
    WindowWidth = 1024
    WindowHeight = 768
    menu #quiz, "BASIC", "[ 5 ]",[basicFive], "[ 10 ]",[basicTen], "[ < 10 ]  '+'",[addBelowTen], "[ < 10 ]  '-'",[substractBelowTen], "[ <1 10 ] '+'/'-'",[addLessBelowTen]
    menu #quiz, "[ < 20 ]","[ + ]",[addBelow20],"[ - ]", [substractBelow20],"[ + / - ]",[addLessBelow20]
    menu #quiz, "About", "About Paolo Maths", [about]
    graphicbox #quiz.done, 5,5,1008, 650
    button #quiz, " Again ", [buttonAgain], LR, 40,10
    open "PAOLO ƾï" for graphics_nsb_nf as #quiz
    print #quiz, "font ";quizFont$
    print #quiz, "color black"
    print #quiz.done, "font ";boardFont$
    print #quiz.done, "color white"
    print #quiz.done, "backcolor darkgreen"
    print #quiz, "when characterInput [numberEntry]"
    call resetQuiz

    print #quiz, "cls"
    print #quiz, "goto ";quizXStart;" ";quizYStart
    print #quiz, "\Please select a test."
    print #quiz, "flush"

    wait


[about]
    notice "About Paolo Maths" + chr$(13)+ "it is a Just BASIC Application" + chr$(13) + "to help Paolo Wong practise Maths."+chr$(13)+chr$(13)+ "by his father"
    wait

[basicFive]
    testType$ = "basicFive"
[startNewQuiz]
    call resetQuiz
    call newQuizItem
    wait

[basicTen]
    testType$ = "basicTen"
    goto [startNewQuiz]

[addBelowTen]
    testType$ = "addBelowTen"
    goto [startNewQuiz]

[substractBelowTen]
    testType$ = "substractBelowTen"
    goto [startNewQuiz]

[addLessBelowTen]
    testType$ = "addLessBelowTen"
    goto [startNewQuiz]

[addBelow20]
    testType$ = "addBelow20"
    goto [startNewQuiz]

[substractBelow20]
    testType$ = "substractBelow20"
    goto [startNewQuiz]

[addLessBelow20]
    testType$ = "addLessBelow20"
    goto [startNewQuiz]

[buttonAgain]

    if testType$="" then wait
    goto [startNewQuiz]

[numberEntry]
    key$=Inkey$
    if testType$="" or itemCount=20 then wait
    if key$ = chr$(13) then
        if val(entryStr$)=val(ansStr$) then
            print #quiz.done, "\";quizHead$;quizMid$;quizTail$
            print #quiz, "flush"
            itemCount = itemCount +1
            if itemCount<20 then
                call newQuizItem
            else
                print #quiz, "cls"
                print #quiz, "goto ";quizXStart;" ";quizYStart
                print #quiz, "\GOOD !  ";time$("seconds")-timeStart;" seconds  ";errCount;" error(s)"
                print #quiz, "flush"
            end if
            wait
        else
            call showEntry "red"
            entryStr$=""
            errCount = errCount + 1
            wait
        end if
    end if
    If instr("0123456789-.",key$) then
        if len(entryStr$)<len(ansStr$) then
            entryStr$=entryStr$+key$
        else
            entryStr$=left$(entryStr$,len(entryStr$)-1)+key$
        end if
    else
        if key$=chr$(8) or (len(key$)>1 and right$(key$,1)=chr$(46)) then
             if len(entryStr$)>0 then entryStr$=left$(entryStr$,len(entryStr$)-1)
        end if
    end if
    call showEntry "lightgray"
    wait



'### subroutines or functions start at here


    '(setup environment for a new series of quiz)
sub resetQuiz
    print #quiz.done, "fill darkgreen"
    print #quiz.done, "goto ";boardXStart;" ";boardYStart
    print #quiz, "backcolor white"
    print #quiz, "cls"
    print #quiz, "setfocus"
    itemCount = 0
    timeStart = time$("seconds")
    errCount = 0
end sub


    '(prepare a new quiz item according to testType$ and testLevel; default=add)
sub newQuizItem
[nextNumberSet]
    select case testType$
        case "basicFive"
            '(working with 5)
            c = int(rnd(1)*4)+6 : b = 5
            format$ = "123456"
        case "basicTen"
            '(working to or from 10)
            c = 10 : b = int(rnd(1)*(c-2))+1
            format$ = "2356"
        case "addBelowTen"
            '(addition within 10)
            c = int(rnd(1)*7)+3 : b = int(rnd(1)*(c-1))+1
            format$ = "14"
        case "substractBelowTen"
            '(substraction within 10)
            c = int(rnd(1)*7)+3 : b = int(rnd(1)*(c-1))+1
            format$ = "2356"
        case "addLessBelowTen"
            '(addition or substraction within 10)
            c = int(rnd(1)*7)+3 : b = int(rnd(1)*(c-1))+1
            format$ = "123456"
        case "addBelow20"
            '(addition within 10)
            c = int(rnd(1)*9)+10 : b = int(rnd(1)*(c-1))+1
            format$ = "14"
        case "substractBelow20"
            '(substraction within 10)
            c = int(rnd(1)*9)+10 : b = int(rnd(1)*(c-1))+1
            format$ = "2356"
        case "addLessBelow20"
            '(addition or substraction within 10)
            c = int(rnd(1)*9)+10 : b = int(rnd(1)*(c-1))+1
            format$ = "123456"
    end select
    if c=lastC and b=lastB then goto [nextNumberSet]
    lastC=c : lastB=b
    call newSimpleQuiz format$
end sub

    '(prepare a new add quiz item arranged randomly from selected formats)
    '(--- there are six possible formats for c,b pairs (c>b) in positive integer sum or less calc.
sub newSimpleQuiz formatSelect$
    a = c - b
    i = int(rnd(1)*len(formatSelect$))+1
    select case mid$(formatSelect$,i,1)
        case "1"
            quizHead$ = str$(b)+" + "+str$(a)+" = "
            quizMid$ = str$(c)
            quizTail$=""
            ansAt$="mid"
        case "2"
            quizHead$ = str$(b)+" + "
            quizMid$ = str$(a)
            quizTail$= " = "+str$(c)
            ansAt$="mid"
        case "3"
            quizHead$ = str$(a)
            quizMid$ = " + "+ str$(b) + " = " + str$(c)
            quizTail$=""
            ansAt$="head"
        case "4"
            quizHead$ = str$(c)
            quizMid$ = " - "+ str$(b) + " = " + str$(a)
            quizTail$=""
            ansAt$="head"
        case "5"
            quizHead$ = str$(c)+" - "
            quizMid$ = str$(a)
            quizTail$= " = "+str$(b)
            ansAt$="mid"
        case "6"
            quizHead$ = str$(c)+" - "+str$(b)+" = "
            quizMid$ = str$(a)
            quizTail$=""
            ansAt$="mid"
    end select
    call showQuiz
end sub


sub initAnsBox answer$
    ansStr$ = answer$
    ansStart = quizCursor
    ansLen = len(answer$)+1
    entryStr$ = ""
    quizCursor = quizCursor + ansLen
    call drawAnsBox "lightgray"
end sub


sub drawAnsBox color$
    print #quiz, "backcolor ";color$
    print #quiz, "goto ";quizXStart+int(quizChrWidth*ansStart);" ";quizYStart
    print #quiz, "\";space$(int(2.4*(len(ansStr$)+1)))
end sub


sub showStr quizLine$
    print #quiz, "backcolor white"
    for i = 1 to len(quizLine$)
        print #quiz, "goto ";(quizXStart+quizChrWidth*quizCursor);" ";quizYStart
        print #quiz, "\";mid$(quizLine$,i,1)
        quizCursor = quizCursor + 1
    next
end sub


sub showQuiz
    print #quiz, "color black"
    print #quiz, "backcolor white"
    quizCursor=0
    print #quiz, "cls"
    if ansAt$="head" then call initAnsBox quizHead$ else call showStr quizHead$
    if ansAt$="mid" then call initAnsBox quizMid$ else call showStr quizMid$
    if ansAt$="tail" then call initAnsBox quizTail$ else call showStr quizTail$
    print #quiz, "flush"
end sub





sub showEntry color$
    call drawAnsBox color$
    i = len(ansStr$)
    j = len(entryStr$)

    while j > 0
        print #quiz, "goto ";quizXStart+int(quizChrWidth*(ansStart+i-0.5));" ";quizYStart
        print #quiz, "\"; mid$(entryStr$,j,1)
        j = j-1
        i = i-1
    wend
    print #quiz, "flush"
end sub
 

« Last Edit: Jan 10th, 2010, 7:57pm by Janet Terra » User IP Logged

scwong
New Member
Image


member is offline

Avatar




PM


Posts: 9
xx Re: Creating Your First Executable Program (.EXE)
« Reply #26 on: Jan 10th, 2010, 6:27pm »

continue from previous post:

the error log is:

Quote:
Error log timestamp Sunday 10/01/10 04:51:36 pm

Runtime error: index: 0 is outside of collection bounds

Error(Exception)>>defaultAction
Error(Exception)>>activateHandler: <anUndefinedObject>
Error(Exception)>>handle
Error(Exception)>>signal
Error class(Exception class)>>signal: <'index: 0 is outside ...'>
OrderedCollection(Object)>>error: <'index: 0 is outside ...'>
OrderedCollection(IndexedCollection)>>errorInBounds: <0>
OrderedCollection>>at: <0> put: <0>
BasicVariableManager>>assignByName: <'1'> toBe: <0.0>
BasicNumericFnDef(BasicFnDef)>>readVariablesFromStream: <aMixedFileStream>
BasicFnDef class>>fromStream: <aMixedFileStream>
BasicRunProgram>>readFnDefsFromStream: <aMixedFileStream>
BasicOnDemandCompiler class>>readTknFile: <aMixedFileStream> callingProgram: <anUndefinedObject> commandLine: <''>
Basic class>>start
Message>>perform
NotificationManager>>empty
NotificationManager>>runPendingEvents
NotificationManager>>runEventLoop
Message>>perform
Message>>evaluate
Process>>safelyEvaluate: <aMessage>
Process>>evaluate: <aMessage>



Thank you for your help.
« Last Edit: Jan 11th, 2010, 03:54am by Stefan Pendl » User IP Logged

Janet Terra
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Female
Posts: 3061
xx Re: Creating Your First Executable Program (.EXE)
« Reply #27 on: Jan 10th, 2010, 8:07pm »

It's unlikely the problem lies in your code. It has to be in either how you're creating the tkn or where the tkn is being saved. Which Windows verion are you using, XP, Vista, or 7? If you're using either Vista or 7, then reread Rob's reply that immediately precedes your code posting.

Did you rename the JB root directory jbrun101.exe to myprogram.exe or did you copy jbrun101.exe to another folder and then rename it to myprogram.exe?
User IP Logged

Janet Visit me at BASIC Samplings
Stefan Pendl
Administrator
ImageImageImageImageImage


member is offline

Avatar

Let's talk JB ...


Homepage PM

Gender: Male
Posts: 3712
xx Re: Creating Your First Executable Program (.EXE)
« Reply #28 on: Jan 11th, 2010, 04:09am »

Are you running on an Asian Windows version?

In addition, you are missing an important thing in your code, which leaves a running process in the background, if you close the window.

Mandatory Code:
'...
    open "PAOLO ƾï" for graphics_nsb_nf as #quiz
    #quiz "trapclose [quit]"
'...
[quit]
    close #quiz
    end

[about]
    notice "About Paolo Maths" + chr$(13)+ "it is a Just BASIC Application" + chr$(13) + "to help Paolo Wong practise Maths."+chr$(13)+chr$(13)+ "by his father"
    wait
'...
 

User IP Logged

Stefan - Homepage

Remember to read the forum rules board wink

Just BASIC 1.01, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
scwong
New Member
Image


member is offline

Avatar




PM


Posts: 9
xx Re: Creating Your First Executable Program (.EXE)
« Reply #29 on: Jan 11th, 2010, 06:08am »

I am using the traditional chinese version of XP servic pack 3. My program is under the JB root directory.When I use the jbrun101.exe, I duplicate it and then do the renaming.

I have added the mandatory code. I think it is very important. Thanks.

I have tried deleting the chinese characters from the window title although the runtime problem till remain.

It puzzles me because the program seems OK in bas and in the IDE.
User IP Logged

Pages: 1 2 3 4  5 Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls