locked
July Challenge: Code Sample RRS feed

  • General discussion

  • Once I read someone asked "Is there sample code for each operation of Small Basic?" (I forgot where and who...)

    My suggestion is to write simple sample codes for following categories in Small Basic.

    Keywords

    • If Then ElseIf Else EndIf
    • For To Step EndFor
    • While EndWhile
    • Sub EndSub
    • Goto

    Operators

    • =
    • + - * /
    • And Or

    Objects (properties / operations / events)

    • Array
    • Clock
    • Controls
    • Desktop
    • Dictionary
    • File
    • Flickr
    • ...


    Nonki Takahashi


    Saturday, June 11, 2016 7:20 AM

All replies

  • This is my sample for If statement: WKV187.

    This is another sample for Array object: JSM615.


    Nonki Takahashi

    Saturday, June 11, 2016 7:24 AM
  • This is the sample of Mouse object: MWC343-0.

    Nonki Takahashi


    Thursday, June 23, 2016 9:10 PM
  • This is my version for While EndWhile statement

    The turtle start drawing random circles  with colors.

    The While y <> 6 is the key to stop the drawing where you want, and stop the program to run.

    program no: VXQ678

    Saturday, July 2, 2016 3:21 PM
    Answerer
  • This is my version for While EndWhile statement

    The turtle start drawing random circles  with colors.

    The While y <> 6 is the key to stop the drawing where you want, and stop the program to run.

    program no: VXQ678

    Thank you for your sample, YLed.

    Nonki Takahashi

    Monday, July 4, 2016 10:08 AM
  • For Keywords, I found examples in help of Small Basic IDE.
    ' Following code initializes a variable flip for If statement example.  [*]
    coin = "1=Head;2=Tail;"
    flip = coin[Math.GetRandomNumber(2)]
    
    ' If
    ' The If statement allows you to make decisions to do different things.
    
    ' Example
    ' The following example will print out either "Win" or "Lose" depending on the outcome of 
    ' the flip.
    
    If flip = "Tail" Then
      TextWindow.WriteLine("Win")
    Else
      TextWindow.WriteLine("Lose")
    EndIf
    
    ' For
    ' The For statement allows you to execute a set of statements multiple times.
    
    ' Example
    ' The following example will print out numbers from 1 to 10
    For i = 1 To 10 
      TextWindow.WriteLine(i)
    EndFor
    
    ' While
    ' The While statement allows you to repeat something until you achieve a desired result.
    
    ' Example
    ' The following code will print a set of random numbers until one that is greater than 100
    ' is encountered.
    While i < 100
      i = Math.GetRandomNumber(150)
      TextWindow.WriteLine(i)
    EndWhile
    
    ' Following line shows how to call a subroutine. [*]
    Win()
    
    ' Sub
    ' The Sub (Subroutine) statement allows you to do groups of things with a single call.
      
    ' Example
    ' The following example defines a subroutine that rings the bell and prints "Win".
    
    Sub Win
      Sound.PlayBellRing()
      TextWindow.WriteLine("Win!")
    EndSub
    
    ' This line is to wait before starting example for Goto statement. [*]
    TextWindow.Pause()
    
    ' Goto
    ' The Goto statement allows branching to a new location in the program.
      
    ' Example
    ' The following program will print consecutive numbers endlessly.
    start:
    TextWindow.WriteLine(i)
    i = i + 1
    Goto start
    Lines with [*] are added to complete the examples.

    Nonki Takahashi



    Monday, July 4, 2016 10:15 AM
  • Here is some samples for the statement:   Sound.Playmusic

    program no: JPN513

    for musical symbols:

    https://en.wikipedia.org/wiki/List_of_musical_symbols

    • Edited by YLedEditor Wednesday, July 20, 2016 5:12 PM
    Wednesday, July 20, 2016 5:06 PM
    Answerer
  • I wrote a blog about sample codes.
    Small Basic - Gather Code Samples

    And, created a TechNet Wiki article also.
    Small Basic: Sample Code


    Nonki Takahashi


    Friday, July 22, 2016 6:18 AM
  • update: VXQ678-0

    • nicer colors
    • faster draw
    • less codelines
    Friday, July 22, 2016 1:46 PM
  • I wrote a sample code for KinectFaceList object: LGR919.

    Screen shot of a program KinectFaceList Sample


    Nonki Takahashi

    Monday, August 15, 2016 1:06 PM