locked
Post your sample source code here and get featured on our blogs! (Part III)

    General discussion

  • Adding to Litdev's comment "do all the main work in the main program loop - and just use events to set control flag variables" you need to also do the following.  In your main program loop, don't ever directly use the flags set in events, unless you only look at them once in the loop path.  Make a copy first in the main loop, then use that copy until the end of the loop.  Then again grab a new copy back at the top. 

    This prevents you from having whacky problems assuming the flag won't change on you in the main loop.  Somethign that should be brought up in the tutorial documentation, if it isn't already.

    ================================

    This thread is a continuation from:

    http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/b1b383c1-6b13-49c0-bf29-00de86103ac6

    Thursday, April 01, 2010 8:36 PM

All replies

  • I got the 3-d bug and made a game starting point, import http://smallbasic.com/program/?QSW885

    The coordinate system it uses should be the easiest for people to understand.  If you're facing north then looking down, X is positive to your right, and Y is positive to the north, like textbook cartesian coordinates.  Z is altitude, positive going up to the sky.  Camera attitude is just like an airplane heading-pitch-roll.  It was a bit of a pain to get it like this, so my pain is your gain!  Please use for your next 3-d project.

    I think some fairly interesting games could be made with this, even ground based games like first-person shooters.  You could replace the plotted points with images, though you'll have to scale & possibly rotate them to look somewhat decent.  I'm working on my next project...

    Thursday, April 08, 2010 9:36 PM
  • Hi. Here Is Small Basic Tetris V 5.0 : JDF211 or http://www.smallbasic.com/smallbasic.com/program/?JDF211

    (This Program Needs FC Extension)

    And Sorry My Bad English

    Sunday, April 11, 2010 5:44 PM
  • Very impressive program - only suggestion is that it speeds up a bit as the score goes up to make it a little harder.
    Tuesday, April 13, 2010 10:20 PM
    Moderator
  • Hi. I Updated Small Basic Tetris to V 5.1.

    Link to my program:

    http://public.bay.livefilestore.com/y1pSnzNDg3x7c2tfxJY3wvH3Qss42udsiHjtvXS1vIeD9yryhqh6lcYHClRra4VqQYwguOJ_2jBs8nsyawyd8Z5_g/TETRIS.zip

    It was too big for small basic server.

    (This Program needs FC and Spawn extensions)
    Sorry My Bad English
    Sunday, April 18, 2010 6:00 AM
  • Hi. This is my programm from Russia. I am 9 years old and I am studying Small Basic.

    VKJ260-0 This game "Tower of Hanoi"

    Good luck.

    Saturday, April 24, 2010 8:40 PM
  • Alex, congratulations.  You're on this week's Small Basic blog.  http://blogs.msdn.com/smallbasic/

     

    Monday, April 26, 2010 7:43 PM
    Moderator
  • Alex, congratulations.  You're on this week's Small Basic blog.  http://blogs.msdn.com/smallbasic/

     


    Thanks for your congratulations. I hope another my programms will be on this site very soon.

     Now I am studying Small Basic with my daddy. But it is not enough materials for children education. My daddy try to create a studying book for me, because I am not very good in English yet. 

    Monday, April 26, 2010 8:33 PM
  • Alex_2000

    Awesome game program you have created!

    I programmed Towers of Hanoi in Applesoft Basic back in 1983, in my teen age years.  Yours is better looking and the only sound I had was a beep if you placed a large disk on a smaller on, and then a lot of beeps when you win.

    Interesting that you used Stack.Push - I need to look into what Stack.Push does that using a variable doesn't.

    The program code is very good, and the fact that you are 9 makes it exceptional (at least in my humble opion).
    One small suggestion is to make comments in your code so that; 1. you can remember what you were doing in any part of your code, and 2. so other people can know what you were doing.
    With your commenting include the program name and version, and give yourself credit, at the beginning.

    Monday, May 03, 2010 7:51 PM
  • Here is my first attempt to do something useful with Small Basic. 

    Simon game : BHK073

     

    I hope you'll enjoy.

     

    PS : with silverlight, when you loose the alert window doesn't appear, do yo know why ? 

    • Edited by Yoc Monday, May 10, 2010 10:13 AM
    Sunday, May 09, 2010 9:49 PM
  • Nice game of simon
    Monday, May 10, 2010 3:47 AM
  • Hi folks.

    Several months have passed since I used Smallbasic for writing SOkoCUTE. This time I provide you a little Picture-Shuffle-Game, called CRACKERS. I really did it in no-time (Smallbasic is awesome guys).

    LINK --> Import LJH960

    LINK --> From here you can download the complete game

     

    And, btw, I finally corrected the few mistakes in SOkoCUTE. A few stages weren't playable without modifying the source. LINK --> SOkoCUTE-Source

     

    PS: Unfortunately Silverlight seems to have some problems with the windows size in crackers (its scaled I guess) an so the "GO"-button wont be appear in the center of the window

    Tuesday, June 08, 2010 9:07 PM
  • First out the door, here is a quick and dirty version of rock-paper-scissors that uses the buttons of the new control object.

     

    Import Code: CMJ212

     

    Enjoy.

    Friday, June 11, 2010 5:13 AM
  • Hello,

    This program draws the typical "Hello world" with the shadow on the graphics window.

    import code : TTR427

    http://smallbasic.com/smallbasic.com/program/?TTR427

    Sunday, June 13, 2010 7:06 AM
  • K-Pad Text Editor v0.9

    Import code: CLQ920

    A simple text editor.

    Requires SB 0.9, FC's extension and Speech extension (opitional, if you don't have, just delete the line 28)


    |"| /"/|"""\ /"""\|"| |__ __| /\ |"""\ |"| | |/ / | " / | | || | | | / \ | |\ \ | | | |\ \ | | \ | | || |__ | | / \ | | \ \| | |_| \_\|_|\_\\___/|____| |_| /_/""\_\|_| \___|
    • Edited by Kroltan Monday, June 21, 2010 8:40 PM UPDATED
    Tuesday, June 15, 2010 11:52 PM
  • My first effort with Small Basic.

    Import code HDJ004

    I hope I've done this properly!

    Sunday, June 20, 2010 12:14 PM
  • my first program in small basic..

    i love this enviroment.

    its Conway´s Game of Life with some extras but in the code where some mistakes too,,and some words are in german. sorry.

    import RVR167

    http://smallbasic.com/smallbasic.com/program/?RVR167

    Tuesday, June 22, 2010 9:39 PM
  • Gunthkab,

    Very cool implementation of Conway's Life - works really well with silverlight too.

    Tuesday, June 22, 2010 9:54 PM
    Moderator
  •  

    My first small basic program is an image gallery. It's just my images now, but you can easily change them, if you like.

    import PPG822 

    http://smallbasic.com/smallbasic.com/program/?PPG822

    Wednesday, June 23, 2010 12:55 AM
  • I began converting one of my "Life" programs to Small Basic a few days ago. Written in another "beginners" programming language it uses a colony of 340 x 180 cells and runs at 10 generations a second. After an hour or so Small Basic hadn't even filled the array, let alone started working.

    Arrays really do need some attention, they're far to slow and are implemented in a very odd way. Some custom data types would be nice too, like Pascal's records.

     

    Wednesday, June 23, 2010 7:52 AM
  • djs1568,

    Multidimensional arrays perform very badly and are generally not advisable.  Are you by chance using multi-dimensional arrays?

     

    Wednesday, June 23, 2010 8:03 AM
    Moderator
  • Vijaye,

    Yes, I'm using three arrays 340 x 180, Status, Neighbours and TempCount.

    What I'd like to use is something like this :

     CellType
       Status  :  Boolean
       Neighbours : Integer
       TempCount : Integer
     
      Cell : CellType[340,180]

     

    Wednesday, June 23, 2010 8:21 AM
  • We don't have "record" support in Small Basic.  Probably never will (it is a conscious decision to keep concept count low).

    A workaround (ugly, I admit) is to use three single dimensional arrays that have 61200 (340*180) items.  And use (row*340 + column) as index to access the value.

    Wednesday, June 23, 2010 3:34 PM
    Moderator
  • Thanks Vijaye, I'll give your method a try. If I get it working I'll upload it, can't have too many variations on "Life" can we?

    Shame about the records though, I'd grown rather fond of those.

     

    Thursday, June 24, 2010 7:03 AM
  • He.

    My second program in Small Basic. Yet another Game of Life, BUT in 3D . included is an rotation, but it didn´t work well, so i excluded it. if you want to try the rotation you only had to change one number in the code.

    its very slow with silverlight in the web so import: RRP679

     


    Thursday, July 08, 2010 6:02 PM
  • Wow that's a elaborate program, looks great visually.  I'm going to let it 'live' for a while on my PC.
    Thursday, July 08, 2010 8:19 PM
  • Here is my version BrickBall.

    click http://smalbasic.com/program/?BQT156

    or import program id BQT156

     

     


    Best Regards Martin
    Monday, July 12, 2010 1:47 PM
  • Here is my Addressmanager.  Program id is BTG300.

     


    Best Regards Martin
    Thursday, July 15, 2010 11:31 AM
  • This is a simple alarm clock.  And my first post.

    http://smallbasic.com/program/?MDW647

     

    Wednesday, July 21, 2010 2:45 AM
    Moderator
  • Here is a dump program.  I wrote this program to confirm how to know EOF (end of file).

    http://smallbasic.com/program/?LWH275

    Before running this program, please remove single quotation in line 8.

    Because the system has been commented out File.ReadContents() operation.

    Wednesday, July 21, 2010 9:32 AM
    Moderator
  • Wednesday, July 28, 2010 2:12 PM
    Moderator
  • Hi all!

    Here is a program to help create screen layouts for your programs. Import ID is MZF016. As of right now, it only supports setting buttons, text boxes, and text Shapes (Labels) to the GraphicsWindow.  I'm hoping to add more features in later versions. :) For now, all information about the screen layout is written to an array which is then saved to file.

    The array looks like this:

     

    Objs["GraphicsWindow"]["Title"] ' GraphicWindow's Title
    Objs["GraphicsWindow"]["Width"] ' Width of GraphicsWindow
    Objs["GraphicsWindow"]["Height"] ' Height of GraphicsWindow
    Objs["GraphicsWindow"]["Top"] ' Top coordinate of graphicsWindow
    Objs["GraphicsWindow"]["Left"] ' Left coordinate of graphicsWindow
    
    Objs["Button"][Index]["Name"] ' The Buttons name assigned by Control object
    Objs["Button"][Index]["Type"] ' The Type of the control - "Button"
    Objs["Button"][Index]["Caption"] ' The button's Caption
    Objs["Button"][Index]["x"] ' the x coordinate of the button
    Objs["Button"][Index]["y"] ' the y coordinate of the button
    Objs["Button"][Index]["Width"] ' the width of the button
    Objs["Button"][Index]["Height"] ' the height of the button
    
    Objs["TextBox"][Index]["Name"] ' The Buttons name assigned by Control object
    Objs["TextBox"][Index]["Type"] ' The Type of the control - "TextBox"
    Objs["TextBox"][Index]["Caption"] ' The TextBox's Text
    Objs["TextBox"][Index]["x"] ' the x coordinate of the TextBox
    Objs["TextBox"][Index]["y"] ' the y coordinate of the TextBox
    Objs["TextBox"][Index]["Width"] ' the width of the TextBox
    Objs["TextBox"][Index]["Height"] ' the height of the TextBox
    
    'Labels are text created by the Shape object
    Objs["Label"][Index]["Name"] ' The Label's name assigned by Shape object
    Objs["Label"][Index]["Type"] ' The Type of the control - "Label"
    Objs["Label"][Index]["Caption"] ' The Lable's Text
    Objs["Label"][Index]["x"] ' the x coordinate of the Label
    Objs["Label"][Index]["y"] ' the y coordinate of the Label
    
    
    Use in good health! 

     

    Saturday, July 31, 2010 2:20 PM
  • Here is a modification of Zeven Provincien's Sorting Algorithm Efficiency demo. The modified code can be found at http://smallbasic.com/program/?sortviz-4. It now compares a Quicksort, an Insertion sort and a shell sort.
    Sunday, August 01, 2010 2:35 PM
  • My program clay-pigeon shoting

    The final version is GGV858.

    Use the mouse. shoting = mouseclick

    Program ID HKG657 or

    http://smallbasic.com/smallbasic.com/program/?HKG657

     Version 2 is XGG295

    http://smallbasic.com/smallbasic.com/program/?XGG295


    Best Regards Martin
    Monday, August 09, 2010 5:55 PM
  • Thanks
    Wednesday, August 11, 2010 5:29 PM
  • Many years ago I wrote a program to graph 3D functions to a dot matrix printer.  PKB220 is a version of that program written in smallbasic.  (it's much easier to do if you don't have to track for 8 or 24 pins in the printhead.)
    Monday, August 16, 2010 9:03 PM
  • My first program in Small Basic

    Analog Clock - http://smallbasic.com/program/?KMX174

    Saturday, August 28, 2010 1:09 AM
  • Hello!

    My new program simple calculator for ver.0.9 only

    KWR934 

    Sunday, August 29, 2010 4:08 PM
  • Yvonne Show 1.0

    http://smallbasic.com/smallbasic.com/program/?KMG772

    It's a lil' program of mine that show random pictures of Yvonne Strahovski every few seconds. It can be modified to show other random pictures during execution thanks to the TextWindow.


    Andrew Burton - http://profnano.org
    Wednesday, September 01, 2010 5:02 PM
  • My First time making a progam,and i'm only 10. So It may not be Perfect. This is a game called COUNTERZ. You Have the choice of four counters, and you just have to pick a counter, and your opponent (the computer) will pick a random one. You win if your counter beats your opponents counter. You can name your player and your opponent: Just select name player/opponent in the Menu. There are four counters to choose from. Here are the stats of each counter: Red Beats Blue, Blue Beats Green, Green Beats Yellow, Yellow Beats Red, Green Beats Red, Yellow Beats Blue.

    As you can see some counters are stronger than others. Such as Yellow Beats Two But only is Beaten By One.

    I would suggest naming your Player and Opponent before playing COUNTERZ.

    Import Code: NSF014

     

     

     

    Thursday, September 02, 2010 3:24 PM
  • Okay; Another Program Here

    This One Is Called CrimeSolver. The Queen's Crown Jewels Have Been Stolen And You Have To Find The Culprit And Arrest Him. But Do Not Fear! You Have An Assistant And The Queen As A Witness.

    Import Code: DWK528

    Saturday, September 11, 2010 10:35 AM
  • ComicGold,

    Nice work - it works well and takes a few minutes to work out how to solve the crime.

    As a challenge, see if you can do it without using a GoTo statement.  They cause the program to 'jump around' and in larger programs they can make it hard to work out the 'logical flow' through a program and find bugs or extend the program.  For this reason it is better to try to not rely on them too much.  You may consider using subroutines where you can, this 'isolates' code that performs a specific task and can reduce repetition (duplication of code) and make the 'logical flow' easier to follow.

    I'm only suggesting this because you have obviously gone a long way already working out the logical flow of your program.

    Tuesday, September 14, 2010 8:17 PM
    Moderator
  • Here's one of my first programs in sb

    It's a simple number guessing game.

    http://smallbasic.com/program/?CJC272

    Don't really know how to use fors and whiles but I'm learning.

    Hope you like it!

    Sunday, September 19, 2010 3:12 AM
  • Here's one of my first programs in sb

    It's a simple number guessing game.

    http://smallbasic.com/program/?CJC272

    Don't really know how to use fors and whiles but I'm learning.

    Hope you like it!


    With While-loops: http://smallbasic.com/program/?CJC272-0
    Intro to Small Basic with Vijaye Raji
    Expert to Expert – The Basics of Small Basic
    Sunday, September 19, 2010 1:19 PM
  • Language : Turkish

    echoooo:
    
    TextWindow.Clear()
    y = 20
    x = Clock.Day
    saat = Clock.Hour
    var = 20 - Clock.Day - 1
    dakika = Clock.Minute
    sn = Clock.Second
    TextWindow.Write("Okulun başlamasına ")
    TextWindow.Write(y-x-1)
    TextWindow.Write(" gün, ")
    TextWindow.Write(24 - saat + ((var * 24) + x2))
    TextWindow.Write(" saat, ")
    If dakika > 30 then
     x1 = 60 - (dakika - 30)
     x2 = 7
    Else
     x1 = 30 - dakika
     x2 = 8
    endif
    TextWindow.Write(x1)
    TextWindow.Write(" dakika, ")
    TextWindow.Write(60 - sn)
    TextWindow.Write(" saniye kaldı.")
    TextWindow.Writeline("  ")
    Program.Delay(125)
    Goto echoooo

    Sunday, September 19, 2010 4:09 PM
  • This is my first 1942 game with smallbasic and scrolling background

    http://smallbasic.com/program/?ZZD394

    play with the mouse and enjoy !!

    1942

    Laurent

     

     

    Thursday, October 21, 2010 10:41 PM
  • There are two of my games in Small Basic, the games are in portuguese.

     

    http://www.4shared.com/file/-SoBDkdH/jogo_da_forca.html

    http://www.4shared.com/file/Kx9gkgEC/snake.html


     

    Tuesday, November 09, 2010 9:16 PM
  • My first program.

    A simple game consisting of avoiding and collecting.

    Control the red ball with the arrow keys.

    Collect the blue balls.

    Avoid the yellow ones.

    I would like some feed back on improvements, changes.

    Thank you.

     

    Link

    http://smallbasic.com/program/?KXW612

    Import code

    KXW612

    Edit.

    Importing will work better. I played it myself from the link and it was full of bugs. Sorry.


    nConaghan
    Wednesday, December 08, 2010 12:12 PM
  • I like this game - I scored 20 - the game play is very good, just about the right speed and it gets progressively harder than you would think when you have to juggle getting the timing right to hit the food or plan a route to avoid the yellow pils.
    Thursday, December 09, 2010 9:28 PM
    Moderator
  • Hey, litdev.

    Thanks for taking the time to give my game a look over. Yeah the idea was to build a simple game with increasing difficulty. I hope I have achieved that, keeping in mind its my first real program. Thanks again


    nConaghan
    Friday, December 10, 2010 2:46 PM
  • Hi

    Heres my link for my multiplication tables program.

    http://www.smallbasic.com/program/?HVS550

    Saturday, December 11, 2010 8:40 PM
  • Neat program, tomtiger. I suggest that in the line of code Textwindow.Write("Choose your Time Table!"), you replace either with

    Textwindow.WriteLine("Choose your Time Table!") 'This has a line in your window between the line to read and the line "Choose your Time Table"

    or 

    Textwindow.Write("Choose your Time Table! ") 'This has a space between '!' and ' " '

    No real need, but it's nice to see a space or line between the read


    ~~AirWaves!!~~
    Sunday, December 12, 2010 6:20 PM
  • Hi. This is my new programm. On site (www.rezoh.ru) is full description about creating this game, but only in Russian. 

    MPV757 This game "Minesweeper".

    Изображение

    Play and enjoy. Good luck!!!

    Thursday, December 16, 2010 9:25 AM
  • DBM434

    I correct mistakes in place mines.

    Good luck!

    Thursday, December 16, 2010 6:57 PM
  • my sample code is a Logo!!!

    The commands are 1 , 2 , 3 , 4 , 5 , 6 , 7 and 8

    You can enter with VLF523 or the link

    The code is

    Turtle.Show()
    GraphicsWindow.Title = "Logo"
    TextWindow.Title = "Turtle commands"
    commands:
    speed = Turtle.Speed
    TextWindow.WriteLine ("What do you want the turtle?")
    TextWindow.WriteLine ("1. Move")
    TextWindow.WriteLine ("2. Turn right")
    TextWindow.WriteLine ("3. Turn left")
    TextWindow.WriteLine ("4. Move to")
    TextWindow.WriteLine ("5. Speed")
    TextWindow.WriteLine ("6. Random background color")
    TextWindow.WriteLine ("7. Color Turtle Road")
    TextWindow.WriteLine ("8. Exit")
    TextWindow.WriteLine ("Turtle speed: " + speed)

    i = TextWindow.Read()
    If i = "1" Then
      TextWindow.WriteLine ("How far?")
      o = TextWindow.Read()
      Turtle.Move(o)
    Endif
    If i = "2" Then
      Turtle.TurnRight()
    EndIf
    If i = "3" Then
      Turtle.TurnLeft()
    EndIf
    If i = "4" Then
      TextWindow.WriteLine ("Where? (X, Y)")
      TextWindow.WriteLine ("X")
      x = TextWindow.Read()
      TextWindow.WriteLine ("Y")
      y = TextWindow.Read()
      Turtle.MoveTo(x,y)
    EndIf
    If i = "5" Then
      TextWindow.WriteLine ("How fast?")
      d = TextWindow.Read()
      Turtle.Speed = d
    Endif
    If i = "6" Then
      GraphicsWindow.BackgroundColor = GraphicsWindow.GetRandomColor()
    EndIf
    If i = "7" Then
      TextWindow.WriteLine ("What Color?")
      z = TextWindow.Read()
      GraphicsWindow.PenColor = z
    Endif
    If i = "8" Then
      TextWindow.WriteLine ("Really want to quit?")
      TextWindow.WriteLine ("1. Yes")
      TextWindow.WriteLine ("2. No")
      s = TextWindow.Read()
      If s = "1" Then
        Program.End()
      EndIf
      If s = "2" Then
        Goto commands
      Endif
    Endif
    Goto commands

    Thursday, December 30, 2010 5:53 PM
  • K-Pad 1.0

    New features:

    • Multi-language support
    • Text-To-Speech integrated

    Don't have time to tell stories to your kids? Type them and the computer will read it for you!

    Current languages are: English, Portugese and Spanish. With many more to come.

    Import ID: MWB628


    Check out my website: http://k-dev.webs.com/
    Friday, December 31, 2010 6:54 PM
  • Nice work Kroltan,

    Suggestions are for a pause, stop - possibly reading and processing line by line.

    Saturday, January 01, 2011 12:33 AM
    Moderator
  • A couple of games I was playing with,  based on some ideas from programmers on this forum - mainly just having fun trying stuff I found interesting, so some areas could use work to make them more game-like, but the interesting bits (for me) work.  Can be used as working games or see how things can be done and as examples to use bits/extend/modify them.  They are reasonably commented as to what is going on.

    Import ZWD466 - MazePackman

    Import XPP946 - SpaceInvaders

    Import TSG033 - Visuals for a song - save and uncomment the auto-commented File command (used to download and save a sample song) after import

     

    Saturday, January 15, 2011 7:35 PM
    Moderator
  • Feel free to publish this code: http://pastebin.com/RJmbteAY 

    Code is contributed by Oskar Duszynski (12 yo boy) and .. me ;) We're from Poland, EU.

    Cheers!
    AR

    Sunday, February 06, 2011 1:29 AM
  • XKCD viewer: MQJ958.

    This program will allow you to view the webcomic XKCD without a browser. It can retrieve specific comics or the most current. It can then either display it in the graphics window or set it as the user's wallpaper.

    It works by first downloading JSON file for the comic from www.xkcd.com, then parses it for the image URL. It then downloads the image using the imagelist class, and asks the user for an action. It could be used to teach about using the network, file, and imagelist classes.

    NOTE: As a security measure Small Basic automatically comments out file operations. If you want to use this program you will need to uncomment them.

    Sunday, February 06, 2011 9:52 PM
  • I was proud of my SmallBasic code sample, but once here I discovered that TEKGNO had shown something similar in a old post.

    Anyway, here's my general implementation to use Stack object to simulate a function call with parameter and local variables.
    The good is that is a general solutions that uses three different stacks to support function arguments, function return value and function local variables.
    These stacks can be used for all the routines, without changing their names.

    Someone could appreciate also the recursive implementation of the compute of permutation of digits, and the using of bidimensional arrays as function return value.

    I agree with those that ask for function parameters and local variables. In Lisp all the variables are global, unless declared explicity as local. This could be a good approach for SmallBasic too. Anyway, a great product to play with.

    'RecursiveFun - Recursive function that uses Stack objects to implement local variables
    'The recursive function computes all the permutations of max 5 digits
    'Author: Iacopo Vettori - www.iacopovettori.it
    
    BeginProgram:
    TextWindow.Write("Input a number between 1 and 5 (0 to exit): ")
    maxnum = TextWindow.ReadNumber()
    If maxnum < 1 Or maxnum > 5 Then
     If maxnum = 0 Then
      Goto EndProgram
     Endif
     TextWindow.WriteLine("Invalid number.")
     TextWindow.WriteLine("")
     Goto BeginProgram
    EndIf
    
    'Prepares the function call putting the arguments on the "fun_arg" Stack object
    Stack.PushValue("fun_arg", maxnum)
    GetPermutations()
    
    'Retrieves the function result from the "fun_res" Stack object
    result = Stack.PopValue("fun_res")
    
    'Displays the result
    TextWindow.WriteLine("Permutations:")
    For i = 1 to Array.GetItemCount(result)
     For j = 1 To Array.GetItemCount(result[i])
      TextWindow.Write(result[i][j])
     EndFor
     TextWindow.WriteLine("")
    EndFor
    TextWindow.WriteLine("Permutations completed.")
    TextWindow.WriteLine("")
    Goto BeginProgram
    
    EndProgram:
    
    'The recursive function computes all the permutations of max 5 digits
    Sub GetPermutations
     
     'Setup code - saves all the local variables on the "fun_var" Stack object
     Stack.PushValue("fun_var", num)
     Stack.PushValue("fun_var", result)
     Stack.PushValue("fun_var", subresult)
     Stack.PushValue("fun_var", subrescount)
     Stack.PushValue("fun_var", i)
     Stack.PushValue("fun_var", j)
     Stack.PushValue("fun_var", k)
     
     'Setup code - reads the expected arguments from the "fun_arg" Stack object
     num = Stack.PopValue("fun_arg")
     
     'Reset the array used to store the result
     result = 0
     
     'End of recursion: the permutation of only one digit
     If num = 1 Then
      result[1][1] = 1
      Goto ExitFunction
     EndIf
     
     'Calls recursively the function with decremented argument put on the "fun_arg" Stack object
     Stack.PushValue("fun_arg", num - 1)
     GetPermutations()
     
     'Retrieves the result from the "fun_res" Stack object
     subresult = Stack.PopValue("fun_res")
     subrescount = Array.GetItemCount(subresult)
     
     'Builds the new result array
     For i = num To 1 Step -1
      For j = 1 To subrescount
       result[j + (num - i) * subrescount][1] = i
       For k = 1 To Array.GetItemCount(subresult[j])
        result[j + (num - i) * subrescount][k + 1] = subresult[j][k]
        
        'Increments all the digits greater than or equal to i
        If subresult[j][k] >= i Then
         result[j + (num - i) * subrescount][k + 1] = subresult[j][k] + 1
        EndIf    
       EndFor
      EndFor
     EndFor
     
    ExitFunction:
    
     'Exit code - put the result on the "fun_res" Stack object
     Stack.PushValue("fun_res", result)
     
     'Exit code - restores all the local variables from the "fun_var" Stack object
     k = Stack.PopValue("fun_var")
     j = Stack.PopValue("fun_var")
     i = Stack.PopValue("fun_var")
     subrescount = Stack.PopValue("fun_var")
     subresult = Stack.PopValue("fun_var")
     result = Stack.PopValue("fun_var")
     num = Stack.PopValue("fun_var")
    EndSub
    
    Saturday, February 19, 2011 11:50 PM
  • Here is a pathfinder demo that I wrote.   It uses an unweighted Dijkstra algorithm.  Since Small Basic doesn't have a Queue structure its very inefficient.

    The biggest problem I have is that the browser based version misses the KeyUp event often and keys become stucked.  It hasn't happened to me once in the local executable version.

    WDX385

    http://smallbasic.com/program/?WDX385

    Saturday, April 30, 2011 8:15 PM
  • Really amazing program, Kevf4.


    ~~AirWaves!!~~
    Sunday, May 01, 2011 4:32 AM
  • ' Code for Password-secured Databases

    ' Names and keys of all authorized Persons name1 = "Till Lindemann" key1 = "1234" name2 = "George Bush" key2 = "hirnfrei" ' Just style ;) TextWindow.WriteLine("Liste 38") ' Name of Program TextWindow.ForegroundColor = "green" TextWindow.WriteLine("========") TextWindow.WriteLine("") TextWindow.Write("Loading") Program.Delay("300") TextWindow.Write(".") Program.Delay("300") TextWindow.Write(".") Program.Delay("300") TextWindow.Write(".") Program.Delay("300") TextWindow.Write(".") Program.Delay("300") TextWindow.Write(".") Program.Delay("300") TextWindow.WriteLine("complete.") TextWindow.WriteLine("") TextWindow.WriteLine("Please enter your name:") name = TextWindow.Read() TextWindow.WriteLine("Please enter your key:") key = TextWindow.Read() ' Some more style ;) TextWindow.WriteLine("") TextWindow.Write("Processing") Program.Delay("300") TextWindow.Write(".") Program.Delay("300") TextWindow.Write(".") Program.Delay("300") TextWindow.Write(".") Program.Delay("300") TextWindow.WriteLine("complete.") Program.Delay("600") ' Copy: ' One block for each authorized Person If name = name1 Then If key = key1 Then Goto output EndIf EndIf If name = name2 Then If key = key2 Then Goto output EndIf EndIf Goto error output: TextWindow.ForegroundColor = "#bbccff" TextWindow.WriteLine("") TextWindow.WriteLine("- Entry 1") Program.Delay("40") TextWindow.WriteLine("- Entry 2") Program.Delay("40") TextWindow.WriteLine("- Entry 3") TextWindow.WriteLine("") Goto end error: TextWindow.ForegroundColor = "red" TextWindow.WriteLine("Wrong name or key!") end: TextWindow.WriteLine("") TextWindow.ForegroundColor = "yellow"
    Sunday, May 01, 2011 5:40 PM
  • I haven't had time to look at the code yet, but I like the way the program runs. Don't know if you programmed it or if it a side affect from running it off the web, but I like the way the little guy bounces off the wall too.
    Friday, May 20, 2011 8:29 PM
  • wow nice, i respect you, however a mute button would be appreciated. May i have permission to use these scrips in my own project?

     

    p.s you english is very good.

    Tuesday, June 07, 2011 2:52 PM
  • Here is a Flickr program .  Import QVK058

    No keyboard input , only mouse click to set a serach word to get a photo by Flickr.

     

     

    Thursday, July 07, 2011 6:32 AM
  • It has no END-SUB this is the error because the program does not go
    Tuesday, October 11, 2011 9:49 PM
  • A simple program to draw multiple colorful polygons using LOGO turtle. the code id is: GCT231

    Sides = 7
    Length = 80
    RepeatNumber = 100
    GUI()
    
    Sub GUI
      GraphicsWindow.DrawText(0,0,"Sides =")
      SidesText = Controls.AddTextBox(50,0)
      Controls.SetTextBoxText(SidesText,Sides)
      GraphicsWindow.DrawText(220,0,"Length =")
      LengthText = Controls.AddTextBox(280,0)
      Controls.SetTextBoxText(LengthText,Length)
      GraphicsWindow.DrawText(450,0,"Repeat Number =")
      RepeatNumberText = Controls.AddTextBox(560,0)
      Controls.SetTextBoxText(RepeatNumberText,RepeatNumber)
      Controls.AddButton ("Draw it!!",0,25)
      Controls.ButtonClicked = Draw
      Turtle.Speed=10
    EndSub
    
    Sub Draw
      Sides = Controls.GetTextBoxText(SidesText)
      Length = Controls.GetTextBoxText(LengthText)
      RepeatNumber = Controls.GetTextBoxText(RepeatNumberText)
      If Sides > 2 Or Length > 0 Or RepeatNumber > 0 Then
        GraphicsWindow.Clear()
        GUI()
        Turtle.Show()
        Turtle.PenUp()
        Turtle.MoveTo (GraphicsWindow.Width / 2, GraphicsWindow.Height / 2)
        Turtle.Angle = 0
        Turtle.PenDown()
        red = 0
        green = 0
        blue = 0
        ColorStep = Math.Floor(255 / RepeatNumber / Sides * 3 * 2)
        For j = 1 to RepeatNumber
          Polygon ()
          Turtle.Turn (360 / RepeatNumber)
        endfor
      EndIf 
    EndSub 
    
    Sub SetColor
      GraphicsWindow.PenColor=GraphicsWindow.GetColorFromRGB(red , green , blue)
      If red + ColorStep < 255 And red + ColorStep > 0 Then
        red = red + ColorStep
      ElseIf green + ColorStep < 255 And green + ColorStep > 0 then
        green = green + ColorStep
      elseif blue + ColorStep < 255 And blue + ColorStep > 0 then
        blue = blue + ColorStep
      Else
        ColorStep = -ColorStep
      EndIf
    EndSub
    
    Sub Polygon
      Turtle.PenDown()
      For i=1 To Sides
          SetColor()
        Turtle.Move (Length)
        Turtle.Turn (360 / Sides)
      EndFor
    EndSub
        
    


    Friday, October 21, 2011 6:30 PM
  • The ID for this program is FZH002.
    It may be found at http://smallbasic.com/program/?FZH002

    'Small Basic Helical Gear
    'Author:          Joseph Watson
    'Date:              30 Oct 2011
    'Notice:           I created this program from scratch and I offer it to you in the public domain. Use it in whatever way you wish.
    'Description: This program generates a three dimensional view of a spur or helical gear. The gear's parameters may be
    '                         adjusted according to the user's wishes. Such parameters include the gear's location in the image, its size,
    '                         its number of teeth, etc. This program does not generate the image with a true involute gear tooth profile
    '                         but does produce fairly convincing images anyway.
    'Note:               I am a retired software engineer with more than 40 years of experience but this is my first program in Small Basic.
    GearXPos             = 320  'Locates the gear in the horizontal direction in the GraphicsWindow
    GearYPos             = 300  'Locates the gear in the vertical direction in the GraphicsWindow
    GearAvgRadius        = 200  'Establishes the gear's general size
    GearTeethHeight      =  50  'Determines how large the gear's teeth are.
    GearNumberTeeth      =  24  'Must be a whole number, the number of teeth on the gear.
    GearToothAngleFactor =  .1  'Values between -.3 and +.3 seem best with 0.0 representing a spur gear.
    GearThickness        = 100  'Larger numbers create a thicker gear
    GearHoleDia          =  40  'The size of the hole in the center of the gear.
    '
    GraphicsWindow.Show()
    GraphicsWindow.BackgroundColor = "Brown"
    YFactor = .3
    ZFactor = .5
    GearHoleRadius  = GearHoleDia / 2
    For Z = 0 To GearThickness * ZFactor Step .5
      For An = 0 To 2 * Math.Pi Step .005
        R = GearAvgRadius + Math.Cos(An * GearNumberTeeth + Z * GearToothAngleFactor) * GearTeethHeight / 2
        X1 = X
        Y1 = Y
        X = GearXPos + R * Math.Cos(An)
        Y = GearYPos - Z + R * Math.Sin(An) * YFactor
        IF An > 0 THEN
          HexDigit = Text.GetSubText("0123456789ABCDEF", Math.Round(16 * (R - (GearAvgRadius - GearTeethHeight / 2)) / GearTeethHeight), 1)
          GraphicsWindow.PenColor = "#" + HexDigit + HexDigit + HexDigit + HexDigit + HexDigit + HexDigit 
          GraphicsWindow.Drawline(X1, Y1, X, Y)
        EndIf
      EndFor
    EndFor
    For An = 0 To 2 * Math.Pi Step .005
      R = GearAvgRadius + Math.Cos(An * GearNumberTeeth + (GearThickness * ZFactor * GearToothAngleFactor)) * GearTeethHeight / 2
      XHoleEdge = GearXPos + GearHoleRadius * Math.Cos(An)
      YHoleEdge = GearYPos - GearThickness * ZFactor + GearHoleRadius * Math.Sin(An) * YFactor
      GraphicsWindow.PenColor = "Black"
      GraphicsWindow.DrawLine (GearXPos, GearYPos - GearThickness * ZFactor, XHoleEdge, YHoleEdge)
      GraphicsWindow.PenColor = "Navy"
      GraphicsWindow.DrawLine (XHoleEdge, YHoleEdge, GearXPos + R * Math.Cos(An), GearYPos - GearThickness * ZFactor + R * Math.Sin(An) * YFactor)
    EndFor
    • Edited by ebjoew Monday, October 31, 2011 4:35 AM
    Monday, October 31, 2011 4:31 AM
  • Very nice ebjoew.
    Monday, November 21, 2011 11:13 PM
    Moderator
  • Continued here due to thread length.
    Monday, November 21, 2011 11:21 PM
    Moderator