Beginner question

User avatar
dE.niz
Posts: 17
Joined: Tue Jan 27, 2015 10:35 am
My devices: Ipad 2 / iphone 4s / macbook / imac .
Location: Belgium
Flag: Belgium

Beginner question

Post 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

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Beginner question

Post 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?

User avatar
Mr. Kibernetik
Site Admin
Posts: 4782
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Beginner question

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

User avatar
dE.niz
Posts: 17
Joined: Tue Jan 27, 2015 10:35 am
My devices: Ipad 2 / iphone 4s / macbook / imac .
Location: Belgium
Flag: Belgium

Re: Beginner question

Post 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

User avatar
dE.niz
Posts: 17
Joined: Tue Jan 27, 2015 10:35 am
My devices: Ipad 2 / iphone 4s / macbook / imac .
Location: Belgium
Flag: Belgium

Re: Beginner question

Post 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

User avatar
Mr. Kibernetik
Site Admin
Posts: 4782
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Beginner question

Post by Mr. Kibernetik »

dE.niz wrote:Is Smart Basic based on Q basic?
Smart BASIC is based on ECMA-55 Minimal BASIC.

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Beginner question

Post 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:

User avatar
dE.niz
Posts: 17
Joined: Tue Jan 27, 2015 10:35 am
My devices: Ipad 2 / iphone 4s / macbook / imac .
Location: Belgium
Flag: Belgium

Re: Beginner question

Post 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

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Beginner question

Post 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)

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Beginner question

Post by Henko »

And a 4th solution : put "option base 1" at the beginning of your program

Post Reply