Page 1 of 2

Beginner question

Posted: Wed Feb 11, 2015 9:57 am
by dE.niz
I'm trying to learn Smart Basic with simple programming.
I am just a beginner.
Now i try to make a game to find words.
in the program i ask if you want to play or not
if yes then can you select with how many letters you will play.
if you want to stop then push the button stop
when i run the program i can only push the first button
i have many, many things tried but i can't find it to make al the buttons work.
the program is on dropbox and here is the link.

https://www.dropbox.com/sh/9865tt9prv2r ... D5Yba?dl=0

my second question is how to make a array
my last question is how to start a wave file without a button

Thanks in advance
please be patient i'm just a beginner

Denis

Re: Beginner question

Posted: Wed Feb 11, 2015 11:27 am
by Henko
Not everybody is using dropbox (at least I don't).

An array is made by the DIM statement, it is mentioned in the help section.

What do you mean by a "wave" file?

Re: Beginner question

Posted: Wed Feb 11, 2015 12:43 pm
by Mr. Kibernetik
dE.niz wrote: my last question is how to start a wave file without a button
Please read "Music" section of documentation.
Especially about commands MUSIC LOAD and MUSIC PLAY.

Re: Beginner question

Posted: Wed Feb 11, 2015 1:48 pm
by dE.niz
Henko wrote:Not everybody is using dropbox (at least I don't).

An array is made by the DIM statement, it is mentioned in the help section.

What do you mean by a "wave" file?
Thank you for the reaction.
Click on the link and you can download my prog
Not a " wave" file but a "wav" sorry my fault

Denis

Re: Beginner question

Posted: Wed Feb 11, 2015 1:52 pm
by dE.niz
Mr. Kibernetik wrote:
dE.niz wrote: my last question is how to start a wave file without a button
Please read "Music" section of documentation.
Especially about commands MUSIC LOAD and MUSIC PLAY.
Thank you for the reaction
I have the documentation printed but for me it is hard to understand.
Ooh love to see little examples in the documentation.
Is Smart Basic based on Q basic?

Thank you for SBasic i love it .
Denis

Re: Beginner question

Posted: Wed Feb 11, 2015 2:09 pm
by Mr. Kibernetik
dE.niz wrote:Is Smart Basic based on Q basic?
Smart BASIC is based on ECMA-55 Minimal BASIC.

Re: Beginner question

Posted: Wed Feb 11, 2015 4:26 pm
by Henko
dE.niz wrote:I'm trying to learn Smart Basic with simple programming.
I am just a beginner.
Now i try to make a game to find words.
in the program i ask if you want to play or not
if yes then can you select with how many letters you will play.
if you want to stop then push the button stop
when i run the program i can only push the first button
i have many, many things tried but i can't find it to make al the buttons work.
the program is on dropbox and here is the link.

https://www.dropbox.com/sh/9865tt9prv2r ... D5Yba?dl=0

my second question is how to make a array
my last question is how to start a wave file without a button

Thanks in advance
please be patient i'm just a beginner

Denis
REM Buttons

Buttons:
BUTTON 1 TEXT "4 letters"AT 120,500 SIZE 130,50
BUTTON 2 TEXT "5 letters"AT 300,500 SIZE 130,50
BUTTON 3 TEXT "6 letters"AT 480,500 SIZE 130,50
BUTTON 4 TEXT “Stop”AT 300,600 SIZE 130,50

IF BUTTON_PRESSED("1")=0 THEN GOTO Buttons ELSE
GOTO Clearscreen
endif
IF BUTTON_PRESSED("2")=0 THEN GOTO Buttons ELSE
GOTO Clearscreen
ENDIF
IF BUTTON_PRESSED("3")=0 THEN GOTO Buttons ELSE
GOTO Clearscreen
ENDIF
IF BUTTON_PRESSED("4")=0 THEN GOTO Buttons ELSE
GOTO Clearscreen
ENDIF
Hi, you can only push the first button, because the programcode handling the other buttons can never be reached... : if you don't push button 1, control goes back immediatly to the buttons label. The code for checking the other buttons is not executed. When you do push button 1, control goes to the clearscreen label, and the code for the other buttons is bypassed (as it should be!).


A working code setup could be (in pseudo code):

Define 4 buttons (before the buttons label)

Buttons:

If button(1) is pressed then
Code to process button(1) activities
Goto clearscreen
End if
If button(2) is pressed then
Code to process button(2) activities
Goto clearscreen
End if
If button(3....etc. etc.
If button(4....etc.

Goto buttons
Clearscreen:

Re: Beginner question

Posted: Thu Feb 12, 2015 10:58 am
by dE.niz
Henko
sorry for the late replay

Thank you
my programming problem is solved
I been lookin in al my books but you gave me the right answer
I see now what I did wrong, now I can finally continue.

can tell me what I am doing wrong here

dim woord$ (3)
for a = 1 to 3
read woord$ (a)
next a
print woord$ (1)

data "een","twee","drie"

Thanks in advance

Denis

Re: Beginner question

Posted: Thu Feb 12, 2015 11:46 am
by Henko
Hi,
You define an array of 3 strings. By default, those have indices (0), (1), and (2) .

Then you try to fill strings with indices (index a) (1),(2), and (3), but string(3) does not exist.

3 solutions to this problem

1. Augment the dim statement for 4 strings (string(0) will not be used then), or
2. Change the for statement to for a=0 to 2, or
3. Change the index : read string(a-1)

Re: Beginner question

Posted: Thu Feb 12, 2015 11:51 am
by Henko
And a 4th solution : put "option base 1" at the beginning of your program