Wee Basic Manual

A. Operation

NOTE: There is no ‘run’ command.  Press the A or START key to run your program.  Press ‘X’ to load a program (text) file and press ‘Y’ to save a program (text) file.  You can also use the dashboard on the bottom screen which contains icons to save, load and run a program (just tap the relevant icon with finger or stylus).

BREAK: hold ‘A’ and ‘Start’ at the same time to break a running program (eg if you get stuck in an infinite loop)

B. Commands/statements etc

1. Statements

rem

Description: leave a comment or remark in a program.

Usage: rem [any symbol or letter as a comment] *

Everything between “rem” and “*” is ignored by the interpreter.

Examples:

rem This is a program *
rem Hello.  The interpreter will ignore this so I can say whatever I want *

dim

Description: sets aside memory in the variable table for an array. In Wee Basic, each array must be initialised with dim or using the array will result in an error. There is a maximum of 100 numerical and 100 string variables. Each string array is limited to 30 members and each numerical array is limited to 100 members.

Usage: dim <variable name>(<number of elements>)

Examples:

dim astring$(5)
dim num(10)
for i=1 to 10
let num(i)=i+1
next

while/wend

Description: loops until a condition is satisfied.

Usage:

while <condition>
[block]
wend

<condition> is a boolean expression
Nested while statements are supported in Wee Basic

Examples:

let x=0
while x=0
let x=key()
wend

if/elseif/else/endif

Description: isn’t it obvious?

Usage:

if <condition> {and/or <condition> {and/or <condition>}… etc}
[block]
[elseif <condition>]
[block]
[elseif <condition>]
[block]
Etc..
[else] [block]
endif

<condition> is a boolean expression, eg >, <, = and <>
Nested ‘if’ statements are supported in Wee Basic

Examples:

input age

if age>12 and age<20 print 1 “you are a teenager”
endif

for/next

Description: isn’t it obvious?

Usage:

for <variable> = <number/variable> to <number/variable [<number/variable]
[block]
next

The syntax at the end, ie “[<number/variable]” is optional and provides a step function.

Nested ‘for’ statements are supported in Wee Basic

Examples:

for i=1 to 10
print 1 i
next

for j=1 to 20 [10]
next

(In this example, j will go from 1 to 11 to 21)

let

Description: Wee Basic requires ‘let’ for all assignments

Usage:

let <string variable> = <string expression>
or
let <number variable> = <number expression>

Examples:

let anumber=5
let astring=”Hello”
if a=5 let b=10
endif

goto

Description: move program execution to specified label

Usage: goto <label name>:

Examples:

lab start:
goto start:

gosub/return

Description: execute subroutine

Usage: gosub <sub name>:

Examples:

gosub start:
end

sub start:
print “This is the start.”
return

print/print at

Description: prints text on specified DS screen

Usage: print s [at x,y] <string or variable>, s is screen

at x,y is optional

Examples:

print 1 “Hello World”
print 0 at 5,5 “This is a program”
print 0 astring$

cls

Description: clears specified DS screen of text and graphics

Usage: cls s, s is screen

Examples:

cls 0
cls 1

end

Description: ends the basic program. Omitting ‘end’ will result in an error and so will placing anything after end (except for subroutines – see ‘sub’)

Usage: end

input

Description: allows the user to input text until <return> is pressed

Usage: input <variable>

Examples: input a$

Note: buggy, better to use key()

lab

Syntax: lab <label name>:
see goto

sub

Syntax: sub <sub name>: [block] return

see gosub

plot

Description: Places a pixel on screen s at x,y

Usage: plot <s> <x>,<y>,<colour>

Note: colour is a number/variable 0-16  (0 is used to erase)

(See line statement for colours)

line

Description: Draws a line on screen s from x1,y1 to x2,y2

Usage: line <s> <x1>,<y1>,<x2>,<y2>,<colour>

Note: colour is a number/variable 0-16 (0 is used to erase)

Colour are:

black 1
blue 2
green 3
cyan 4
red 5
magenta 6
brown 7
white 8
gray 9
light blue 10
light green 11
light cyan 12
light red 13
light magenta 14
yellow 15
bright white 16

keyshow

Description: show the soft keyboard on the bottom screen if hidden

Usage: keyshow

keyhide

Description: hides the soft keyboard on the bottom screen if visible

Usage: keyhide

Note: keyhide MUST be used before displaying anything on the botton screen. Otherwise Wee Basic throws an error (reason is the user will not be able to see anything displayed if the keyboard is present).

createspr

Description: Creates a sprite specified by the file name on the screen specified at the specified coordinates.

Usage: createspr <number>,<screen>,<x>,<y>,<width>,<height>,<file name>

<file name> is a string or string variable. The file must be a gif file for a 256 colour sprite (greater colour depth will cause a crash). The file must be in the root directory of your card.  The others are numbers or number variables

movspr

Description: Moves an existing sprite specified by the number to new coordinates x and Y on the screen.

Usage: movspr <number>, <screen>, <x>,<y>

All input are numbers or number variables

delspr

Description: Deletes the specified sprite.

Usage: delspr <number>, <screen>

All input are numbers or number variables

vflip and hflip

Description: flips sprites vertically and horizontally.

Usage:

hflip <sprite no>,<screen>
vflip <sprite no>,<screen>

backgr

Description: Creates a background on the specified screen with the gif file specified by the file name.  The file must be 256 colours and in the root directory of your card.

Usage: backgr <screen>, <file name>

Note: <file name> is a string or string variable. The file must be a gif file. Screen is 0 or 1.

2. Sounds

– playmp3 [string] {string is file name}

or playmp3 [string],<filename> <volume>,<pan>,<bitrate>  (each is an integer or number variable)

File must be in the root directory of your card.

plays an mp3 file

– pausemp3

pauses the playing of an mp3 file

– contmp3

continues a paused mp3 file

3. Microphone

– micrec

records from the microphone
will automatically stop recording when buffer is full so no need to manually stop recording

– micpla

plays whatever has been previously recorded from the microphone

4. Expressions

Syntax: let <variable>=<expression>

int(<number expression>)
rnd(<number expression>)
sin(<number expression>)
cos(<number expression>)
tan(<number expression>)
log(<number expression>)
sqrt(<number expression>)
key() – gets key input

returns an integer value for keys pressed as follows:

X: 200
Y: 201
A: 202
B: 203
Left: 204
Right: 205
Up: 206
Down: 207
L: 208
R: 209
Start: 210
Select: 211

keyboard: ascii value

stx() – stylus x coordinate
sty() – stylus y coordinate
stt() – 1 if stylus touches screen, 0 if not

motx – motion x coordinate

moty – motion y coordinate

3. Math symbols

+, -, *, /, ^

4. Motion

– motion (initialises motion – throws an error if motion card is not detected

(see also expressions)

5. Examples

(a) Fun with colours

dim letter$(5)
let letter$(1)=”h”
let letter$(2)=”e”
let letter$(3)=”l”
let letter$(4)=”l”
let letter$(5)=”o”
rem hide the keyboard to use the bottom screen *
keyhide
print 0 at 0,14 “Wee Basic: Fun with colours”
print 0 at 0,15 “Keep pressing a button”
print 0 at 0,16 “to continue”
let j=4
rem test all new 16 colours *
for i=1 to 16
rem draw a line with each colour on each screen *
line 1 j,1,j,30,i
line 0 j,1,j,30,16-i
print 0 at 0,20 “J: “+j+ “i: “+i
let j=j+10
gosub getkey:
next
rem let’s test ‘;’ with print *
for e=1 to 5
print 1 letter$(e);
next
end

rem wait for a key to be pressed *
sub getkey:
let k=0
while k=0
let k=key()
wend
return

(b) Creating and flipping a sprite

createspr 1,1,50,50,32,64,”soldier.gif”
gosub getkey:
hflip 1,1
gosub getkey:
vflip 1,1
gosub getkey:
end

sub getkey:
let k=0
while k=0
let k=key()
wend
return

(Make sure you have a 32×64 sprite named “soldier.gif” in the root directory or this program will raise an error)

(c) Sound

print 1 “A – Pause mp3”
print 1 “B – Continue mp3”
print 1 “right – replay”
print 1 “higher volume/rate”
print 1 “left – exit”
print 1 ” ”
let keya=202
let keyb=203
let right=205
let left=204
let vol=10
let pan=0
let rate=500
lab start:
let k=0
print 1 at 0,20 “Volume:”+vol
print 1 at 0,21 “pan: “+pan
print 1 at 0,22 “rate: “+rate
playmp3 “test.mp3”,
vol,pan,rate
while k<>right and k<>left
if k=keya pausemp3
endif
if k=keyb contmp3
endif
let k=key()
wend
stopmp3
let vol=vol+10
let rate=rate+50
if pan=0 let pan=64
elseif pan=64
let pan=127
elseif pan=127
let pan=0
endif
if vol>=127
let vol=10
endif
if k=right
goto start:
endif
end

(Make sure you have a file named test.mp3 in the root directory or this program will raise an error)

(d) Microphone

let keya=202
let keyb=203
let right=205
let k=0 let rec=0
while k<>keya
if k=right and rec=0
let rec=1
print 1 “Recording….”
micrec
endif
if k=keyb and rec=1
let rec=0
print 1 “Playing….”
micpla
endif
let k=key()
wend
end

(e) rem test

rem hello this should all be ignored*
print 1 “Helllo world”
end

(f) sprite demo

let soldier=1
let bottom=0
let top=1
let keya=202
let keyb=203
let right=205
let left=204
let soldx=5
let soldy=95

cls 1
keyhide
cls 0

gosub topback:
gosub botback:
gosub soldspr:

lab start:

let k=0
let k=key()

if k=keyb
gosub jump:
endif

if k=keya
goto finish:
endif
if k=right or k=left
gosub movsold:
endif

goto start:

lab finish:
end

sub key:
let k=0
while k=0
let k=key()
wend
return

sub topback:
backgr top,”island.gif”
return

sub botback:
backgr bottom,”lake.gif”
return

sub soldspr:
createspr soldier,bottom,
soldx,soldy,32,64,
“soldier.gif”
return

sub movsold:
if k=right
let soldx=soldx+20
movspr soldier,bottom,
soldx,soldy
endif
if k=left
let soldx=soldx-20
movspr soldier,bottom,
soldx,soldy
endif
return

sub jump:
for i=1 to 4
let soldy=soldy-20
movspr soldier,bottom,
soldx,soldy
gosub delay:
next
for i=1 to 4
let soldy=soldy+20
movspr soldier,bottom,
soldx,soldy
gosub delay:
next
return

sub delay:
for j=1 to 10
next
return

(You need all of the gif files in the root directory for this to work)

Advertisements

105 thoughts on “Wee Basic Manual

  1. I need to unjoy weebasic the extended playmp3 fonction: loke that playmp3, canal 1 to …12, volume 1 to 16 polyphonic mp3 sample player !
    do you understand wath i wanna do with my DS !
    the micrec fonction to ex micrec A$”name”,canal 1 to…12 !
    and i’ll be happy with my ds for ever

  2. i wrote an error excuse me for playmp3
    it’s look like that : playmp3[string],canal 1 TO 12,volume

    and the micrec looks like : micrec[string] and micplay[string],canal 1 TO 12,volume

  3. yeesssss ! so good ! yes

    the playmp3 fonction need chanel to use polyphonia sond !

    look than this : playmp3 “nameofmp3”,A$(chanel),v$(volume)

    and the wee basic can make a mp3sequencer !

  4. the microphone fonction look like that in my configuration

    micrec “name of sound”

    micplay “name of sound”,a$(chanel),v$(volume)

    and it make my ds so nice to do voice machine !

    i am so impatient to programming !!!!!

  5. very very very immpoorrttantt !!!

    i forget to tell u a new fonction to playmp3 !!! the rate of playing sample or mp3

    The fonction: playmp3 “nameof mp3”,R$,b$,v$

    r$ is the rate of the sample or mp3 value 0 to 1024
    b$ is the chanel to play on polyphonia with chanel 0 to 12
    v$ is the volume 0 to 255

    and my ds could be a sequencer like QBASE !!!!

  6. To load:

    – press X
    – type the filename eg demo.txt
    – tap enter key on soft keyboard

    To save:

    – press Y
    – type the filename
    – tap enter key

    Have you DLDI patched the rom?

    Please describe the bug

  7. The manual looks good. I’d like to show wee basic to my son who has the DS. So I tried wee06 on no$gba emu, and I can type in a program. I haven’t touched much BASIC since the late 1980s, and the “run” cmd just didn’t work. Finally figured out that I needed to press start. You might want to add that to the user manual. Thanks for creating this. Good luck with it.

  8. Been using it more. (version 0.6) Having some issues with the editor when the listing is longer than the screen will hold. But also getting a lot of syntax errors that are not errors. Strange little changes fix it. For example, Problem with labels. If I just change the name of a label from done1: to done11: the problem goes away. Also nested if not following logic correctly – seems to miss the inside endif statement.
    Do you see these things too?
    But happy to see that filenames can include path, so files don’t have to be in the root directory.
    It’s great to be able to program right on the DS. Thanks again. Do you want me to send samples of code that fail?

  9. s54boc: yes please provide the code that fails – it’s great to have your feedback so that I fix any bugs

  10. Hi

    Only just started to use it, but so far I really love weebasic, but after getting into a loop, is there a key combination that can be used to ‘break’ out of the running of a program?

    That would help me so much. Many thanks.

  11. Great to hear Simon. There is no break command. I’ll put it on the to do list. In the meantime, use a workaround such as using a loop with a variable that can be changed to true if you want to break out of the loop eg

    let i=1
    while(i=1)
    //code
    if [condition] let i=1 //want to break out of the loop
    endif
    wend
    end

    or

    for i=1 to 10
    //code
    if [condition] let i=10 //want to break out of the loop
    endif
    next
    end

  12. s54boc: unfortunately not yet but it’s pretty trivial to implement so I’ll try and get them done in the next version.

  13. Pingback: wee basic ds Flashcards & Homebrew

  14. Cool! I’ve been messing around in WeeBASIC and made a little application that plays kind of like capture the flag, so far its done besides ai, but it doesn’t seem to detect when the keys are held, any ideas?

  15. AI is done BTW, just have to make it detect the flag, make it vulnerable when it’s got the flag, and improve button detection (You have to keep pressing it, while the AI just blows throw it.

  16. sounds great chao1212. At the moment, wee basic only detects key presses rather than keys “held” which is why you have to keep pressing. I can include keys “held” in a later version if you like.

  17. i try run weebasic 0.81 on supercard dsone
    it runs… 🙂 wow
    trying PRINT command

    this code runs
    —-
    keyhide
    print 0 at 0,12 ” Ciao mondo”
    —-

    this code runs with bugs
    —————-
    keyhide
    print 0 at 0,12 ” Ciao mondo”
    print 0 at 12,12 ” Sono anche qui”
    print 0 at 21,12 ” e anche qui”
    —————–
    i get all three string on middle of touchscreen in sequence

    if i run again this code weebasic crush!

    • thank’s for fast answer!
      i haven’t put statement END at the end of program

      output on touchscreen was like this:

      Ciao mondoSono anchequi e anche qui

      how you can see, all three string in sequence!
      in my basic experience this is wrong…
      if i PRINT at X,Y first$
      and then i PRINT at X,Y second$ again
      i must get that second$ overwrite first$ screen_output
      for its lenght! Not this!
      Only in Qbasic PRINT statement I remember the option ‘;’ that force this result.

      Now I try ending code with END statement…
      ok, it runs well
      thank you…
      Now I cancel END statement and I run code again
      it runs well also without END statement…

      where is the bug?

      Now testing this following code all run right! 🙂
      Also without END statement!

      ———————
      keyhide
      print 0 at 1,12 “Ciao”
      gosub aspetta:
      print 0 at 1,12 “coccodrillo”
      gosub aspetta:
      print 0 at 1,12 “gioca”

      sub aspetta:
      let a=0
      while a=0
      let a=key()
      wend
      return
      ———————–

      Sorry for my many questions

      1. How to open codefile save? using open icon or X key
      I get only .SAV e .NDS files …in SD root no folder… oops i wrongly put in a folder weebasic files (wee81samp.txt weebasic.nds)! Now I’ll move them in root. What extension i must search? .SAV?!?

      2. how start a new code project?

      thank you for spending your time !

      • BASIC FaN,

        Maybe there’s a bug with the new code I put in for ‘;’. I’ll check it out.

        In relation to your other questions:

        1. yes – wee basic searches for files in the root directory only. Also wee basic files should just have a .txt extension NOT .sav

        2. at the moment there is no start new project option. Just create a blank file called start.txt and load it each time you want to start a new project. I’ll fix this in a later version.

      • I have tested weebasic also on R4 and all run ok also without END statement, but i got error message coming back in program… 🙂
        all right I’ll search .TXT file for saved and I’ll create new.TXT for new blank TXT file
        Bye and thank’s

  18. BASIC FaN, I’ve tested your code.

    First:

    keyhide
    print 0 at 0,12 ” Ciao mondo”
    print 0 at 12,12 ” Sono anche qui”
    print 0 at 21,12 ” e anche qui”

    This prints all three strings in a row because you have the same y value for each “print at” and the x values are in sequence (ie you don’t have the same x value – there is no overwriting). There is no bug. Also, without an ‘end’ statement I get a “statement expected” error at the end of the program which is exactly what should happen.

    Second:

    keyhide
    print 0 at 1,12 “Ciao”
    gosub aspetta:
    print 0 at 1,12 “coccodrillo”
    gosub aspetta:
    print 0 at 1,12 “gioca”

    sub aspetta:
    let a=0
    while a=0
    let a=key()
    wend
    return

    Here you have the same x and y values which is why each string gets overwritten. Again, no bug. Also I get “statement expected” error without an ‘end” statement which is how it should work.

    Let me know if you have any other questions.

    • Hello freesifistories
      that you said is right … in a second time I’m counting characters in strings of first code… lenght of string is very like to X value used in PRINT 0 AT statement… so i get an effect like “;” option!
      in the second code example I get what you have got! the code runs and come back with a warning “absence of END statement”!
      Ok thank’s…
      I put weebasic file in root of SD of DSone
      now say me please how to save codefile and then load it!
      1) name like “.\name.txt” gets message error… “Save file, Please enter the exact name of the file to save, Cannot open file, press A to continue”
      ok this is a bad name file

      2)name like “111” or “qqq.txt” no gets message error… but opening a file with X button or Open icon I get a short filelist with only .SAV and .NDS files in root!
      first question: How to see .TXT file?
      second question: how many files can list in this function weebasic?

      3) name like “000.sav” or “qqq.nds” no gets message error… but opening a file with X button or Open icon I get a short filelist .SAV and .NDS but I don’t see 000.sav or qqq.nds! How can i solve this?
      thank’s for your time

      • BASIC FaN, wee basic doesn’t allow directory characters such as “./”. You just need to enter the name of the file eg “file.txt”.

        When you use “X” to load, make sure you scroll down the screen using the d pad – up and down. That way you’ll see more files.

  19. yes friend but that OPEN_FILE filelist is too short…
    🙂 just on a SD with 30-40 files and folders at root it runs ok, but on a most crowed (populated) root it fails!
    But with a dedicate SD on DSone it runs ok (few files and folders in root)… no problem 😉

    some questions:
    1.variable type:
    variable are strings (ie stringa$ o let stringa= ” ” or dim stringaArray$(100) if I’ve understood)
    or integer number… in future it will be real number?
    2. INPUT statement: help on this page says “buggy” I must forget INPUT statement?

    thank you very much for spending your time!

    • Okay, I understand. Yes, there’s a 50 file limit in terms of what can be displayed. If you have more than 50 files then the rest won’t display. If there’s enough memory I’ll change this in a later version.

      Strings:

      – have to end in ‘$’ and can have up to 7 characters in their name (there can be 80 characters in the string itself). Eg let a$=”hello” or let string$=”me”
      – you only need to dim arrays. Eg dim a$(10) Let a$(1)=”test”

      Input:
      – you can use input. Eg input a or input string$
      – bugs have been removed to some extent but input always displays in the same place on the screen
      – you can also use key(), which is like inkey$ in old basic

  20. Hello Freescifistories
    can i make any questions?

    1. How can i use stx() sty() stt() ??? Are they global or enviroment variable? are function like key()?

    2. while i’m typing code in weebasic on NDS, when code goes ahead on the next line, the red_text_cursor jumps on first location in row and text after this! So typing i get a mistake! what about this?

    3. running this code i have met this result! Is it a bug o a non explained function of PRINT statement?
    code:
    ———————————
    print 1 at 0,5 “ciao”
    gosub aspetta:
    print 1 at 0,6 “Oggi calcoliamo

    il numero del nome”
    gosub aspetta:
    cls 1
    end

    sub aspetta:
    print 1 at 0,20 “premere un tasto per continuare”
    while key()=0
    wend
    return
    ———————–
    on the screen :

    ciao
    Oggi calcoliamo

    il numero del nome

    premere un tasto per continuare
    —————-
    two empty line on the screen as a result of writing two ENTER on software keyboard … fine 😉

    4. how store data for application? ie qbasic OPEN FILE FOR READ/WRITE or DATA statement?
    Good Job and thank’s for your time

  21. hi
    here is a little fun example utility:
    ASCII.txt to show ascii code in soft keyboard and NDS buttons

    ——————–
    cls 1
    print 1 at 0,1 “Ciao premi i tasti per vedere il codice ASCII qui sotto”
    print 1 at 0,20 “Premere A per terminare”

    let a=0
    while a202
    let a=key()
    if a0 print 1 at 5,5 a + ” ”
    endif
    wend
    end
    ——————
    Bye Bye 🙂

  22. Hi, I see you’ve been busy. Summer has just ended here, so back to the keyboard for me. The last version of weebasic didn’t work on my M3. Seemed to just hang early after start up. Can’t remember the details. I’ll try 0.81.

    • Good to hear from you again s54boc. It’s odd that you couldn’t get the previous version to run. Let me know if you have any problems with this one.

      • I got this one to run. My BASIC programs are under /TXT or /DATA, so I couldn’t load them with the new interface. I used to save my programs like /TXT/prog1.txt. So have not yet exercised the new version. Maybe I can move them using my txtwriter.nds instead of using the PC. Working on an unrelated little DS project of my own right now. Will share when ready.

  23. hi freescifistories
    I’m enjoing with wee basic …
    what about statement MOTION and MOTX MOTY?

    have you a section for free example code to submit?

    have you thinked about an option to run sample code like QBASIC /RUN using file batch (.bat) linecommand?

    or any option to do this?

    thank’s for your time…

    PS webpage doesn’t post “” caracters

    • At this stage, it’s great if you just post example code in the comments here. I can include them in the manual on the next update. On the batch file, do you mean on a windows machine or on the ds? I am working on something for windows.

      • hi
        I’m thinking about NDS, so a good code can be used as an application simply loading it like it happens for .NDS files …so somebody can use it without disrupt code file in some ways…

        ok weewindows is great and at beginning… I’ll wait improvements..

        sorry what is statement MOTION and MOTX MOTY ? How can i use it?

        PS your webposting doesn’t accept disequal (not equal) charaters ie this ”

      • I understand – a runtime for the NDS so you don’t have to open the editor so the basic file runs automatically. I’m working on it.

        For Motion, you need a motion card (r5?). Then you could do something like this:

        rem enable motion*
        motion
        lab start:
        print 1 “motion x=”+motx
        print 1 “motion y=”+moty
        goto start:
        end

        As you move the ds from side to side, motx and moty should change in value.

        About ‘”‘ – this is a wordpress limitation.

  24. Hi freescifistories
    look at this WEEBASIC code
    an example showing text columns and text row on screen 1
    (high screen) and screen 0 (touchscreen):

    _____________________________
    rem conta le righe e le colonne dello schermo
    *

    keyhide
    cls 1
    cls 0
    let a = 0
    let b = 0
    for a = 0 to 31
    print 1 at a,0 “0”
    print 0 at a,0 “0”
    next

    gosub pausa:

    for b = 0 to 23
    print 1 at 0,b b
    print 0 at 0,b b
    next

    gosub pausa:

    let a=0
    let b=0

    for b=0 to 23
    let a=a+1
    print 1 at a,b b
    print 0 at a,b b

    next

    gosub pausa:
    end

    sub pausa:
    print 1 at 15,5 “premere un tasto”
    print 0 at 15,5 “premere un tasto”

    while key()=0
    wend
    return
    _________________

    just a question
    while i cancel by backspace virtual keyboard I get sometimes that weebasic hangs… only two black screen

    oops just another question
    is customible heypad in touchscreen?
    for example is it possible to show only digit or characters?

    Bye and thank for your time

    PS about “” (not equal) characters in code at them position I’ll put NOT EQUAL words in capelock!

    • Good stuff! Not sure why wee basic hangs with backspace – will have to look into it. Unfortunately you can’t customize the keyboard.

  25. hello Freescifistories
    waiting your debugging of backspace hanging here is a fine raw code to paint by pencil on touchscreen
    ——————–
    cls 1

    keyhide

    let a=0
    let b=0
    let c=0
    let d=0

    print 1 at 0,3 “tocca il touchscreen e trascina la stilo”

    print 1 at 0,20 “premi B per terminare”

    print 1 at 0,17 “cambia colore con i tasti SU GIU del pad”

    let d=2

    while a203

    let a=key()

    let b=stx()
    let c=sty()
    if a=206
    let d=d+1
    elseif a=207
    let d=d-1
    endif

    if d>16
    let d=16
    elseif d<1
    let d=1
    endif

    print 1 at 0,7 "x=" + b + " y=" + c + " d=" + d +" "

    plot 0 b,c,d
    wend

    end
    —————————-
    🙂

    PS are there statements like QBASIC ASCII(car$) CHR$(num%) LEN(string$) line x,y,x1,y1,color,B/BF (make square/square full) PLAY(music_string$) CIRCLE x,y,color

  26. hello Freescifistories
    sorry here another code example about graphic screen fulling
    ————
    cls 1
    print 1 at 0,4 “altezza screen 192 pixel”
    print 1 at 0,8 “larghezza screen 255 pixel”

    gosub aspetta:

    let a = 0
    let b = 0
    for a = 0 to 191
    for b = 0 to 255
    plot 1 b,a,4
    next
    next
    print 1 at 0,12 ” coloro schermo intero”

    end

    sub aspetta:
    let z =0

    while z203
    z = key()
    wend
    return
    ——————
    thank’s for your time

  27. hello frescifistories
    I’m often stopped by warning error in weebasic that bring me far to real code error…ie in IF ENDIF embeded statement there is no control couple IF…ENDIF and weebasic report error line far from real bug code…

    otherwise writeing code by stilo on touchscreen isn’t so fun and comfortable… there is no copy_cut_paste routine for code text… so much work for you, to improve your creature.

    bye and thank’s for spending your time

  28. hi freescifistories
    see output of this code please:

    ————————————————–

    rem prova statement grafici in weebasic 0.81 *

    keyhide
    let a = 0
    for a = 0 to 256
    line 0 a,0,a,198,4
    line 1 a,0,a,198,4
    next

    rem this second linecode put out a strange behaviour of
    LINE statement (LINE screen x1,y2,x2,y2,color) on screen 1
    changing color value I get a various character output over graphic output for color value 4 is $ (oh oh the shift keyboard code of 4! :-))
    please try using 3 or 6 as color on screen 1*

    while key()=0
    wend
    cls 0
    rem this line code over doesn’t anything on graphics output… *

    while key() =0
    wend
    cls 1
    rem this line code clear only character on screen 1*

    let b=0
    for b= 0 to 198
    line 0 0,b,256,b,5
    line 1 0,b,256,b,3
    next

    rem in this code there is no problem for output on screen 1*
    end
    ———————————
    thank for spending your time

    • Basic Fan, the cls function only clears text characters, not lines/points. If you want to clear lines or points use the colour ‘0’. Eg:

      rem this clears both screens*
      for a = 0 to 256
      line 0 a,0,a,198,0
      line 1 a,0,a,198,0

      • ok I understand
        1) cls is clear text screen… for graphics i must draw black (or my preferred color) on screen

        2) have you got the same strange behaviour of this code?
        ___________
        let a = 0
        for a = 0 to 256
        line 1 a,0,a,198,4
        next
        _________
        ie characters on graphic output?

        bye and thank’s

  29. Hi freescifistories

    running weebasic interpreter on SD on DSone and on SD R4 I get text over graphics on screen 1 (the other than touchscreen;) that text disappears with cls 1.

    So I don’t get any text characters using no$gba!

    bye and thank’s

  30. Hi freescifistories
    do you like text scrolling ? here an example code…
    ________________

    let b$ = “WEEBASIC”
    print 1 at 0,0 “premere un tasto per iniziare”
    while key() =0
    wend

    print 1 at 0,22 “premere un tasto per terminare”
    while key()=0
    let a = 0
    for a = 0 to (31 – 7)
    print 1 at a-1,12 ” “+b$
    let c=0
    for c = 0 to 2000
    next
    next
    let a = 25
    while a > 0
    let a = a-1
    print 1 at a-1,12 b$ + ” ”
    let c=0
    for c = 0 to 2000
    next
    wend
    wend
    end
    ___________________________

    just a question at this time is possible print text with different color than white?
    If yes How?
    thank’s for spending your time

  31. Hello freescifistories
    here I can post example code:
    vertical scrolling
    _____________________________
    let b$ = “WEEBASIC”
    let giu = 200
    let su = 100
    let a = 0
    let b = 0

    print 1 at 0,0 “premere un tasto per iniziare”
    while key() =0
    wend
    cls 1
    print 1 at 12,22 “premere un tasto per terminare”
    while key()=0
    if b = giu
    if a >23
    let b = su
    end if
    let a = a +1
    elseif b = su
    if a <0
    let b = giu
    end if
    let a = a-1
    endif

    print 1 at 0,a b$

    let c = 0
    for c = 0 to 2000
    next

    wend
    end
    _________________

    bye bye

  32. Sorry for many post:
    can I print extended ascii dos characters? (ie box characters)
    If yes How?

    thank’s for spending your time

  33. hi Freescifistories
    I’m moving towards graphic statements…
    sorry it seem a little tutorial on WEE graphic…

    before run following code you must create 4 .GIF files…
    I have used PAINT on windows Vista … but you can use your preferred graphic software saving in .GIF
    How do you ? easy, run PAINT of windows (TM) or some other software and…
    1) two times you take fullfillpaint tool and choosing your preferred colour fill the white paper on PC screen…
    then save this as .GIF on max 256 colours…
    IE 1.GIF 2.GIF (two different colors)
    at this time don’t care about pixel dimensions…
    2)then for the third image.GIF open a fine file image… ie .BMP or JPG or TIF or other format and SAVE AS .GIF
    IE 3.GIF
    3) now you must reduce image dimensions to 256 X 200 pixels
    (in PAINT you must use resize tool setting it on 50%) and save this as your little .gif
    IE 4.GIF
    now after putting these four files on SD root you can run this example code by WEEBASIC 0.81…
    _________________

    rem prova background*
    keyhide
    print 1 at 0,10 “prova sfondo!”
    gosub attesa:
    backgr 1, “1.gif”
    print 1 at 0,12 “testo su sfondo”
    gosub attesa:
    backgr 1, “2.gif”
    gosub attesa:
    cls 1
    gosub attesa:
    backgr 1, “3.gif”
    gosub attesa:
    backgr 1, “4.gif”
    gosub attesa:
    end

    sub attesa:
    BACKGR 0, “1.gif”
    print 0 at 0,12 “premere B per continuare”
    while key()203
    wend
    while key()0
    wend
    return
    _____________________
    you’ll get this…output on screen 1, while touchscreen is help screen
    1) only text on screen 1
    2)the new background don’t overwrite (cancel) text on screen 1
    3) new text overwrite background…but deleting text with CLS statement on screen don’t change background…
    4)using image like photo o some other picture if it is larger 256X200 pixels (X Y screen dimensions) you’ll get only the area filling screen from up left corner…to down and right… the last area is out
    5) using .GIF with 256 colors max and dimensions 256X200
    you’ll get the whole imagine…filling screen

    bye bye

    just a question about createspr…
    in this code above

    gosub attesa:
    backgr 1, “3.gif”

    if I use createspr statement ie

    gosub attesa:
    createspr 1,1, 20,20,77,58,”3.gif”

    I got this error code:
    Error:sprite width/height not available in char position… XXX near [ZZZZZ]

    STATEMENT is
    CREATESPR number, screen, x,y, width, height, filename

    at first time I’ve red on WEEBASIC manual that .gif must have exactly used GIF dimensions … but if I do so… why this error…? ie if 3.gif is 77×58 pixels?
    thank’s for your time

    • also your code taken from weebasic manual make this error
      ______createspr 1,1,50,50,32,64,”soldier.gif”
      gosub getkey:
      hflip 1,1
      gosub getkey:
      vflip 1,1
      gosub getkey:
      end

      sub getkey:
      let k=0
      while k=0
      let k=key()
      wend
      return
      _________
      what about this?

      • Mixing text and backgrounds can be difficult and is not recommended. You can always create a background with text on it (just use the paint program to create the text).

        Sprite width and height has to be 32×32, 16×16, 8×8, 16×8, 32×8, 32×16, 32×64, 8×16, 8×32, 64×32

        What error did you get with the example code?

  34. hello freescifistories

    1)
    thank’s for additional info about sprite dimensions… now

    this problem is ok
    ___________________________
    if I use createspr statement ie

    gosub attesa:
    createspr 1,1, 20,20,77,58,”3.gif”

    I got this error code:
    Error:sprite width/height not available in char position… XXX near [ZZZZZ]
    __________________

    2)
    BUT running on no$gba the example code at this webpage
    (b) Creating and flipping a sprite…
    I got this error
    ________
    error: statement expect in char position 31 near [,50,32,64,”soldier.g]
    _________
    PS image soldier.gif is loaded in fcsr!

    WHILE trying on SD R4 it’s all OK!…
    I think it is a problem about no$gba compatibility
    with weebasic.nds because also “char on graphic line” don’t happens on no$gba BUT there is while running on SD R4 e DS DSone on NDS light…

    3) mixing text and backgrounds like in my example code
    gives me more possibilities to code using indipendent graphics and text…
    4) yes it’s fine to use image charactes made by paint or other graphics software..

    thank’s for spending your time…

    only two more question about future development of WEEBASIC
    1) possibility to run in batch WEEBASIC SCRITP…
    2) possibility to manage file, at least text file like .txt
    3) possibility to use more primitive graphics to draw CIRCLE, SQUARE, CLS GRAPHICS
    Bye bye

    • Hi – I’m still working on the runtime (like a script) for loading txt files like bat files. With primitive graphics you can use maths to make these with ‘plot’ (eg using pi). CLS graphics is not really required as colour ‘0’ is the same as erase.

      I think there’s a problem with no$gba and FCSR in loading large files. There ends up being some hidden characters at the end of the file which causes the “statement expected” error.

      Keep having fun 🙂

      • OK i’m waiting for news!
        (in order SCRIPT and then Managing Files)
        If i’ll found more time I post some graphics primitive SUBROUTINE made mixing maths and plot or line…
        but just after some little time…

        Thank’s and bye

        PS: I’m sorry because sometimes my english is very bad (caused by little time and more tired) 😦 in spite our communication go on 🙂

  35. In emulator No$gba, after inserting cartridge “WeeBasic.nds”, what have I to do to be able to load and save programs?
    I get “cannot open file” message.

    • Philsan, you get that message because no$gba cannot load files without a disk image being attached to the weebasic.nds file. You can use a program called fcsr to do this or you might try desmume emulator instead. I am working on a program that will do this automatically if you can wait a little longer.

  36. Selecting ‘compact flash’ in the GBA slot and selecting the folder with the .txt file I am able to load and save.
    But when I reset the emulator I lose what I have saved.

  37. Hi freescifistories

    waiting news I’m developing a nice software and I fall in “;” trouble….
    using this code afterdown I get “Ok” at 13 rows and “hello” at the first rows… why ???
    if “;” must attach characters in following sequence starting from the last text position why this trouble?

    here weebasic code
    ————————
    dim letter$(5)
    let letter$(1)=”h”
    let letter$(2)=”e”
    let letter$(3)=”l”
    let letter$(4)=”l”
    let letter$(5)=”o”

    rem let’s test ‘;’ with print *
    let e = 0
    print 1 at 0,13 “ok”;
    gosub getkey:

    for e=1 to 5
    print 1 letter$(e);
    next
    gosub getkey:
    end

    rem wait for a key to be pressed *
    sub getkey:
    let k=0
    while k=0
    let k=key()
    wend
    return
    ——————
    Just another question…
    How many characters can I put in a weebasic_string?
    … using DIM striga$(N) N max is 30?
    … and then in Weebasic charset isn’t printable characters with accent…. Must I convert in 2 characters? (ie à become a’)

    bye bye
    and thank’s for spending your time

    • Sorry basic fan but ‘;’ doesn’t work with print at, only with print. Dim for string is limited to 30 strings. Each string has 79 characters max.

  38. Hello freescifistories
    wellmet in the new year…

    working with strings I meet these troubles
    explained by following soft weebasic code…

    _______________________________________

    dim t$(30)

    cls 1

    let t$(1) = “Il tipo DUE è molto legato alla famiglia, alla tradizione e possiede . ”
    rem 50 caratteri *

    let t$(2) = “0ààààààà1òòòòò2èèèè3ùùùùù4ììììì5çççç6§§§7°°°”
    rem lettere accentate in this order
    0a’ 1o’ 2e’ 3u’ 4 i’ 5 c espanol 6 double s 7 symbol used i.e. for grade celsius*

    let t$(3) = “grandi qualità istintive, sensoriali e umorali.Si adatta facilmente alla”

    rem MAX contained string , the following has been cut to get no error interpeter

    routine della vita quotidiana e, anche se un po’ capriccioso, riesce simpatico. Avrà una realizzazione di destino concreta, anche se con inizio difficile” *

    print 1 at 0,8 t$(1)
    print 1 at 0,13 t$(2)

    while key() =0
    wend
    cls 1
    print 1 at 0,8 t$(3)
    end
    ________________________________________

    if you see output you get these effects:

    1 you cannot align text to get fine output because PRINT instrunction works in variable manner

    2 expecial non english characters aren’t print on screen (no character no space, nothing)

    3 string(X) limit character is 79 but you sometimes gets interpeter error synthax if you fill string… see t$(3) and try to fill it until 79 characters…

    so
    HOW can I format text on screen in suitable manner?

    thanks for your time

    BASIC FaN

    PS
    good improvement to Wee Editor!
    Go on my hero!

    • Thanks BASIC FaN. I tested your code:

      1. t$(1) is too long for one line. This is why it goes to the next line. If you want more control over formatting, break t$(1) into more than one string.

      2. Non English characters are not implemented in the library I use to compile Wee Basic. I’ll do some research on this.

      3. How many characters causes the error eg is 78 okay? Possibly needs some fine tuning.

      • Hello Freescifistories

        Formatting like at 1. I’ve solved my trouble…but if we walk we can explore and I’ve explored WEEBASIC ground and now I find some walls…
        1. no RANDOM function… > no RANDOM generator …
        I have no idea how build it!
        2. no function CHR$() like QBasic… I’m working on this…
        3. no TIME function… I’ve Worked on this but see what I’ve got !?!

        code begins here
        _____________________________________
        rem programma timer *
        print1 at 0,12 “premere un tasto per continuare”
        gosub aspetta:
        print 1 at 0,20 “aspetta 15000 cicli poi cancello”
        let secondi = 3

        rem try to change secondi variable
        more than 5 is buggy!?! … try 10 for example
        *
        gosub tempo:
        cls 1
        print 1 at 0,5 “un tasto per terminare”
        gosub aspetta:
        end

        sub tempo:
        let b = 0
        for b = 0 to secondi
        gosub ritardo:
        next
        return

        sub aspetta:
        while key()=0
        wend
        return

        sub ritardo:
        rem secondo=15000 *
        let a=0
        for a=1 to 15000
        next
        return
        _______________________________
        code ends here…

        I’ve measured 1 sec = 150000 loops for-next
        but increasing seconds to wait function doesn’t work!!!

        What do you think about this ?

        Thank’s for spending your time
        Bye Bye

    • Hi BASIC FaN. There is a random number generator. Just use rnd. Example: let a=rnd(5). When I have time, I’ll implement the other functions.

      • Hi freescifistories
        great and quick response

        thank’s…
        a random generator is very useful for many porpouse
        from give cards on cardgame to bingo game to many other game engine that need casuality seed

  39. Dear Freescifistories
    I put here code of my creature
    “NUMEROLOGO version 0.1 ”

    code begins here
    _______________________________

    dim testo$(30)

    cls 1

    gosub lingua:
    print 1 at 0,0 testo$(1)
    print 1 at 0,2 testo$(2)
    print 1 at 0,3 testo$(3)
    print 1 at 0,5 testo$(4)
    keyshow
    gosub stop:
    end

    sub stop:
    let a=0
    let b=0
    let c=0
    WHILE KEY()10

    let a=key()
    if a>64 and a96 and a9
    print 1 at 0,20 testo$(5)
    let b=b-9
    wend
    keyhide
    print 0 at 0,10 testo$(6) +” “+ b
    return

    sub lingua:
    let testo$(1)=””
    keyhide
    print 0 at 5,10 “ENGLISH”
    print 0 at 20, 10 “ITALIANO”
    print 0 at 12,6 “FRANCAISE”
    while testo$(1) = “”
    while stt() = 0
    wend
    let b = stx()
    let c = sty()
    if c>43 and c95 and b75 and c 39 and b 155 and b < 224
    gosub italiano:
    endif
    endif

    rem the following codeline are for debug
    print 0 at 0,23 testo$(1)+ " "
    let testo$(1)=""
    *

    wend
    return

    sub francese:
    let testo$(1)= "Bonjour"
    let testo$(2)= "Bienvienue in NUMEROLOGO"
    let testo$(3)= "maintenant je suis calculer"
    let testo$(4)= "S'il vous plait, ecrivez le nom avec le stylet"
    let testo$(5)= "Je figurer la valeur du nom"
    let testo$(6)= "Le nom ecrit appartient a la famille du nombre "
    let testo$(7)= ""
    let testo$(8)= ""
    return

    sub inglese:
    let testo$(1)= "Hello"
    let testo$(2)= "Welcome in NUMEROLOGO"
    let testo$(3)= "now I'm computing…name's number…"
    let testo$(4)= "please, write name by stilo"
    let testo$(5)= "computing value of name"
    let testo$(6)= "Name written is in the range of number "
    let testo$(7)= ""
    let testo$(8)= ""
    return

    sub italiano:
    let testo$(1)= "Ciao"
    let testo$(2)= "Benvenuto in NUMEROLOGO"
    let testo$(3)= "ora calcolo…il numero del nome…"
    let testo$(4)= "prego, scrivi il nome con la stilo"
    let testo$(5)= "calcolo il valore del nome"
    let testo$(6)= "Il nome digitato appartiene alla famiglia del numero "
    let testo$(7)= ""
    let testo$(8)= ""
    return
    _______________________________
    code ends here

    try it and let me know what do you think about…

    Bye Bye

    PS: I've got a bug with stilo touch…
    try to touch over ENGLISH and ITALIANO text ie at right and at left of FRANCAISE text … or at top or at bottom of touchscreen and see what happens… 🙂

  40. Dear Freescifistories just some times after the last time that I wrote I’ll come back….
    to create more funny codesoftware by Wee Basic
    I need to make some questions…
    1. can I use files grouped in a folder?
    2. at what point is the “run” project like Qbasic dos?
    3. is possible using file.txt “open read write close”?

    thank’s for spending your time…
    bye bye

    • Hi BASIC Fan.
      1. sorry, files have to be in the root directory of the ds
      2. not sure what you mean by this
      3. unfortunately, not yet.

      Good to have you back.

      • hello Freescifistories
        1. ok only root… but if I use too many items (file image GIF and sound MP3) I must use as cards as project in development to not gain confusion

        2. it’s possible that WeeBasic project can run pushing a button of NDS console for example the A button and not be necessary to load first Weebasic, then load filecode in Weebasic and at the end pushing the A button run the project….

        3.in a game how can I save important data? for example SCORE GAME, Name of user, checkpoint level, etc etc?

        greating you for your time
        Bye Bye
        BASIC FaN

  41. Hi,

    I really could do with this for iPad, your calc is fine but I don’t want to use the simple scripting that is available in that app. and I don’t actually need a calc. I would really miss the Basic dialect as well. Any chance of an iPad version of Wee basic now? Esp. now Apple has relaxed the rules in the latest TOS regarding scripting?

    Many thanks for reading,

    Ian

    • Ian, I’d love to do a basic interpreter for ipad but the new TOS would require Apple’s express permission. Not even an organisation like Unity has been able get Apple’s express permission for their product. I am convinced that Apple would reject an application that does nothing but scripting because it may be perceived as competing with the App store. Apple would not even allow the basic interpreter to be included in the C64 emulator – despite the fact that it would be running in a sandbox and is for an outdated platform. My fear is that I would waste a lot of effort only to be rejected.

      What else would you like to see in terms of commands/statements in SophistimaCalc?

  42. Hi again, well I understand your point.

    Hmmm, well it would nice if the calculator language supported, in order of precedence…

    Functions / Sub’s

    Proper loops, with a ‘next’ or equivalent to mark the end of the looping section.

    ‘if’ ‘then’ with logical operators

    Anything like that would make me a happy camper 😉

    Many thanks,

    Ian

    • Ian, I’m not sure this will help, but:

      – Subs: use ‘call’ with a separate file for each sub. Variables are global
      – For/next: repeat is supposed to help but I acknowledge doesn’t automatically increase a variable eg

      mem i=0
      repeat 2 i<10
      mem i=i+1
      i

      Is equivalent to: for i=1 to 10, print i, next

      – if/then: use cond. All usual operators are supported (see manual). I acknowledge else if/else not supported, but you can work around this limitation
      – Functions: let me have a think

  43. Hi again,

    Yes that would work fine but the syntax is a little unwieldy (numbering the lines in your loops for example). I suppose the problem is with syntax. I have never programmed a calculator but I imagine the syntax is based on this?

    Still its an option, none-the-less… many thanks.

    Ian

  44. Hi Frescifistories
    in this hot August I’m thinking about how send to you the package of a whole project made with Weebasic so you can put it on your website…

    I wish you a good Ferragosto (15 August is an holyday here)

    BASIC Fan

  45. Would you please revisit Wee-BASIC and the Wee-BASIC Manual?

    My son has been having stability issues with v82; v82a doesn’t even run for him (locks up on the loading screen of an AceKard 2i w/AKAIO 1.8.9z)
    Would love to see a PDF manual, that states which version of Wee-BASIC it’s for and with examples showing the use of each command.

    • Screen scraped your online manual, cleaning it up a bit for my son.
      I now believe my son’s complaint about instability is due to the backspace bug… he mentioned two black screens.
      I’ve read though a lot of the posts here, Simon has made many good suggestions.
      Adding a “NEW” command to start writing a new program, instead of loading in a blank *.BAS program would be useful.
      How long can a filename be? Does (upper/lower) case matter?
      It would be nice to write my own data/text/graphic file to my uSD card.
      Screen captures would be nice, selecting: 0, 1 or 2 for both.
      It would be nice if Wee-BASIC didn’t save/load everything to the root of my uSD card, perhaps create a WeeBASIC directory as a default.
      Please allow for the loading of alternate fonts – and please switch to one of Simon’s new fonts as default.

  46. Pingback: The end of my weekly Nintendo DS serial « Marovada's discombobulation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s