none
Challenge of the Month -January 2014 RRS feed

  • General discussion

  • HAPPY NEW YEAR!

    These challenges are intended for people who are learning to program for the first time or for those returning to programming who want to start using SmallBasic.  Some will be easy, some will be hard - but they will all make you think, and more importantly be GREAT FUN!

    Please post your solutions / partial solutions / questions / feedback etc. into this thread that will remain 'sticky' for the month.  The only rule is that your solution must use standard SmallBasic methods (no extensions).

    It would be good if people could post their problems with these challenges so that a discussion can start so that everyone can learn from each other.

    Also post feedback on the kind of challenges that you want to see more of in the future.

    Curriculum Challenges 3.1

    1. Write a subroutine that can be called to welcome a user and tell them how long it was since they last started SmallBasic - Hint store the last time in a file in the current Program.Directory.
    2. List all of the SmallBasic files in current Program.Directory.
    3. Create a file in the current Program.Directory and use it to store a some sums that can be added to for the text challenge bellow.

    Text Challenges

    1. Write a program that can do as many of the following sums as you can and output the answers.  The sums are input at text strings like "25+3" which need to be scanned and interpreted (parsed) to find the numbers and operations to do the sum (this is a Text challenge).  The program should read the sums from a file (created by curriculum challenge 3 or created manually).  Add or share more sums to test each other's programs.

    Example sums

    • 25+3
    • 15.7*91
    • -12-8
    • sqrt(81)
    • 5+sqrt(9)
    • (7+5)/4

    Graphical Challenges

    1. Make a simple graphical calculator.  Perhaps the user enters 2 numbers in 2 textboxes and then presses one of 4 buttons to +, -, *, / with the result given in a third textbox.

    Maths Challenges

    1. Write a program to calculate the number of ways that a 'full house' can be chosen by picking 5 cards from a normal pack of cards.  A full house has 3 of a kind and 2 of a kind.  Perhaps also do some other poker hands like a flush or straight. 
    2. You can try doing it randomly to get the approximate probability of such hands.  Remember any card can only be picked once so if I have already got two 8s, the chances of getting a third are reduced.

    Game Challenge

    1. Write 'pairs game' where the players have to find image pairs.  Something like this.

    Community Suggestions (by Nonki)

    1. Draw G clef and F clef.
    2. Draw wave figures of chords (e.g. C major, F minor, G 7th).
    3. Make a scoreboard for any sports.

    Challenges by Jibba Jabba

    Properties and Operations

    Briefly explain the difference between an Operation and a Property.  Using the words "has" and "does". - for beginners.

    TextWindow Challenge: - for intermediate skill level

    Write a program that changes the TextWindow backgroundColor to all the colours available to the TW and display (animate) the current color's name in the TW.title.  To set TW.backgroundColor: 1st set the color then clear the window.

    Good Coding Techiniques

    Identify/discover the usefulness of using good variables as opposed to just plugging values straight into functions and methods. This is a 1st step toward writing extensible code. May as well briefly define a function and method too.  This article can help:  Small Basic: Programming Tips

    GraphicsWindow Challenge: - for beginner gamers

    Using your good variables add a box (rectangle) or a ball (ellipse) and continuously move it from one side of the window to the other so that no part of the shape leaves the window but the Shape touches the edge. Use Shapes.Move method and not Shapes.Animate().

    You can further advance this (intermediate skill level) by using acceleration so that the shape is moving at its fastest in the centre of the GW and slowest at the edges.

    Do you have an idea for a future challenge? Please post it here!

    • Edited by litdevModerator Wednesday, January 1, 2014 10:26 PM clarification
    Wednesday, January 1, 2014 7:40 PM
    Moderator

All replies

  • ' TextWindow Challenge (v1.0)
    ' by GoToLoop (2014/01)
    '
    ' http://social.msdn.microsoft.com/Forums/en-US
    ' /fdca984f-881e-43bb-9931-4256333575b7/challenge-of-the-month-january-2014
    
    colors = "0=Black;1=Blue;2=Green;3=Cyan;4=Red;5=Magenta;6=Yellow;7=Gray"
    count = Array.GetItemCount(colors)
    total = count * 2
    current = 0
    
    Loop:
    If current = 0 Or current = count - 1 Or current > count And current < total - 1 Then
      name = colors[Math.Remainder(current, count)]
    ElseIf current > 0 And current < count - 1 Then
      name = "Dark" + colors[current]
    ElseIf current = count Then
      name = "Dark" + colors[count - 1]
    Else
      name = "White"
    EndIf
    
    TextWindow.Title = name + " #" + current
    
    TextWindow.BackgroundColor = name  ' by color name
    'TextWindow.BackgroundColor = current  ' by color value
    
    TextWindow.Clear()
    Program.Delay(2000)
    
    current = Math.Remainder(current + 1, total)
    Goto Loop

    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Thursday, January 2, 2014 12:42 AM
    Answerer
  • Another soulution to the set TW.b/ground colour and TW.Title property. Thanks goto for sharing the idea of using the Title to display program info.

    I've got another program that animates the title back and forth. I reckon running a banner in the title could be useful.

    string[1] = "Black,Blue,Cyan,Gray,Green,Magenta,Red,White,Yellow,DarkBlue,"
    string[2] = "DarkCyan,DarkGray,DarkGreen,DarkMagenta,DarkRed,DarkYellow,"
    string = Text.Append(string[1], string[2])
    
    For i = 1 To Text.GetLength(string)
      TextWindow.Title = colour  
      colour = Text.Append(colour, Text.GetSubText(string, i, 1))  
      If Text.GetSubText(string, i, 1) = "," Then    
        TextWindow.BackgroundColor = Text.GetSubText(colour, 1, Text.GetLength(colour)-1)   
        TextWindow.Clear()
        colour = ""
        Program.Delay(800)
      EndIf  
      Program.Delay(40)
    EndFor

    Thursday, January 2, 2014 9:03 PM
    Moderator
  • Define Properties & Operations:

    A property is something that a Small Basic object has, e.g. TextWindow.BackgroundColor is a property that the TW HAS.

    An operation is something that a Small Basic object does, e.g.  TextWindow.Clear() is an operation that TW can DO.

    Is an operation the same thing as a method?

    Thursday, January 2, 2014 9:16 PM
    Moderator
  • Is an operation the same thing as a method?

    Yup! And method/operation is just a special OOP term for when functions/procedures/subroutines are tied to a class/object.

    Same for field/property, which is for variables tied to a class/object.  :D


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Thursday, January 2, 2014 9:47 PM
    Answerer
  • Thanks goto for sharing the idea of using the Title to display program info.

    Actually, I think it's 1 of the challenge's requirements:

    TextWindow Challenge: - for intermediate skill level

    Write a program that changes the TextWindow backgroundColor to all the colours available to the TW and display (animate) the current color's name in the TW.title.  To set TW.backgroundColor: 1st set the color then clear the window.


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Thursday, January 2, 2014 9:49 PM
    Answerer
  • Thanks for the clarifying the field/property too.

    re: other thanks. I got the idea for the challenge from your other posts. I've learnt heaps from your posts.

    Here's another exercise sample that animates the title back and forth. I think this would be more useful if it was run as a banner (continuously running from left to right).

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

    Thursday, January 2, 2014 10:15 PM
    Moderator
  • My solution for the treble clef challenge.

    GXT088-0.

    Sunday, January 5, 2014 9:31 AM
    Moderator
  • Wow, nice art!

    Nonki Takahashi

    Sunday, January 5, 2014 3:53 PM
    Moderator
  • This is my sample for community suggestion by Nonki 3: FVG576.

    Screen shot of a program Baseball Scoreboard 0.1

    Use keyboard to control this board.  Click once in remote.


    Nonki Takahashi

    Sunday, January 5, 2014 3:57 PM
    Moderator
  • Thanks. I was a bit slack with the code though.

    Would've been more useful if I made it resizable.

    Sunday, January 5, 2014 4:40 PM
    Moderator
  • Neat scoreboard. Top idea for an app.

    When I was a kid I used to buy a cricket scoreboard book from the newsagent and keep score.

    Sunday, January 5, 2014 4:43 PM
    Moderator
  • Here's an alternative to draw treble clef. XWL927

    It scans a web image, saves the graphic data to file then retrieves and draws.

    The data file is 40KB. Would probably be better if I buffered the graphic data then write it to the file in bundles.

    I'm interested in trying this to store the coordinates (outlines only) of complex shapes for mouse detection etc. Can use 3rd party software to design the b/ground, shapes, sprites and collect some key coordinates and use for game play. Maybe.


    Sunday, January 5, 2014 5:14 PM
    Moderator
  • This is my sample for community suggestion by Nonki 1: FQH921.

    Screen shot of a program Musical Score 0.1


    Nonki Takahashi

    Monday, January 6, 2014 9:06 AM
    Moderator
  • This is my first program for maths challenge 2: RMP814.

    Current simulated probability of full house is 133/78460 = about 0.0017 = 0.17%. 

    Screen shot of a program Full House Simulator 0.3


    Nonki Takahashi

    Tuesday, January 7, 2014 2:08 PM
    Moderator
  • Game Challenge   'pairs game'  MQP008

    * this game gets photos from Flickr.  so you can change the tag.  

      and you can change setopacity level.

    Tuesday, January 7, 2014 2:08 PM
    Answerer
  • This is the result of the second simulation with RMP814.

    143/100000 = 0.00143 = 0.143 %

    Screen shot of a program Full House Simulator 0.3 with 100000 times trial

    This program is slow... It tooks a half day for trying 100000 times. 

    Nonki Takahashi

    Wednesday, January 8, 2014 3:49 PM
    Moderator
  • @Nonki Looks quite close to here
    Wednesday, January 8, 2014 9:02 PM
    Moderator
  • Hello everyone, I am back after a long time.

    Here is my solution to TextWindow Challenge: - for intermediate skill level

    Code : XMD073


    Merry Xmas!

    Thursday, January 9, 2014 9:13 AM
  • Hey 4mir

    What a neat solution. Like your creative spin on the title scrolling & description. Your extra touch is entertaining. And thanks for the helpful code sample. Good stuff.

    Thursday, January 9, 2014 3:42 PM
    Moderator
  • I looked around for a Unicode for a treble and bass clef. Found some but couldn't get them to show in word or wordpad. :(

    Thursday, January 9, 2014 3:55 PM
    Moderator
  • This is a really entertaining forum I reckon.

    Hey NaochanON. Good stuff.

    This is more entertaining than the web sample, I think because the tiles are a bit bigger and the tag. I love cats so it's easier for me to remember their faces. Great idea to consider the user when coding. I appreciate the choice features of tag (it's either cats or birds for me) and the opacity cheat code. Cool.

    I like playing easy to pick up, straight forward games as a de-stresser / relaxer. I think it's a reasonable and positive health initiative. I often play match 3's and love low cost with lots of variety. The more the merrier. With some online results posted with leader boards.

    SB forum is becoming a new game hub for me.:)


    Thursday, January 9, 2014 4:59 PM
    Moderator
  • This is a really entertaining forum I reckon.

    Hey NaochanON. Good stuff.

    This is more entertaining than the web sample, I think because the tiles are a bit bigger and the tag. I love cats so it's easier for me to remember their faces. Great idea to consider the user when coding. I appreciate the choice features of tag (it's either cats or birds for me) and the opacity cheat code. Cool.

      Thank you for your reply.  I love cats too.

    When posting in this forum, I am willing to introduce you some new techniques( for me).

    This time, I thought the following two.
    1)Images downloaded from web to be zoomed to the same size and align them.

    I thought of a way .   It is exprained by the following equation:
     the position  ( zoomed)  will be
    X = X0 - IMG_W / 2 + zoom_W / 2 ,
    Y = Y0 - IMG_H / 2 + zoom_H / 2

    2)If you obtain  images from Flickr, sometimes you  get the same images. (Flickr.getrandomphotos) 
    and sometimes you fail to get a photo.
    This program shows  how to avoid them.

    pLZ refer.


    Friday, January 10, 2014 2:19 AM
    Answerer
  • Thanks Naochan, I got some good ideas from your code.

    I like your method for getting a unique random Flickr, IsSubText(url).

    A random Pic is not necessarily a unique pic.

    Like you zoomScaleRatio too.

    Here's an alternative I might try for the resizing of the image, it also exploits the layers of the GW.

    Layer1 = GW.BackGroundColor, Layer2 = GW.Pixels  & Layer3 = Shapes on Top of GW.Pixels:

    path = "C:\Users\Public\Pictures\Sample Pictures\Koala.jpg"
    image = ImageList.LoadImage(path)
    
    tileSize = 120
    
    GraphicsWindow.DrawResizedImage(image, 0, 0, tileSize, tileSize)
    
    '========================================================
    'indexing the above  -  Initialise()
    '========================================================
    'gridDimension = 5   '5 rows by 5 columns
    tileSize = 100
    row = 2
    column = 3
    
    GetUniqueRandomPaths()
    LoadImages()
    'AddShapeCovers()
    DrawTiles()   'draw tiles underneath the Shape covers 
    
    Sub GetUniqueRandomPaths
      'If unique Then
      'For row = row To gridDimension
      randomFlickr[row * column] = "C:\Users\Public\Pictures\Sample Pictures\Koala.jpg"
    EndSub
    
    Sub LoadImages
      'For row = row To gridDimension  
      tile[row * column] = ImageList.LoadImage(randomFlickr[row * column])
    EndSub
    
    Sub DrawTiles  
      'For row = row To gridDimension
      GraphicsWindow.DrawResizedImage(tile[row * column], row * tileSize, column * tileSize, tileSize, tileSize)
    EndSub
    
    

    Friday, January 10, 2014 11:44 AM
    Moderator
  • I just double checked drawing underneath the Shape Covers. It works fine:

    Sub AddShapeCovers
      cover[row * column] = Shapes.AddRectangle(tileSize, tileSize)
      Shapes.Move(cover[row * column], row * tileSize, column * tileSize)
    EndSub

    Friday, January 10, 2014 11:51 AM
    Moderator
  • Howdie, just thought I'd pass this on (bring it to your attention). Might be able to use it for one of the challenges :)

    Source: http://www.jaysonjc.com/programming/small-basic-language-tutorial-programming-is-fun.html

    Is there a way to pass parameters to a subroutine in small basic?

    Small basic language doesn’t support parameters in the case of subroutines. In fact the only type of variable supported are the global variables. However it is possible to simulate subroutine parameters using the Stack object as shown below,

    Stack.PushValue("p",45)
    Stack.PushValue("p",55)
    Sum()
    TextWindow.WriteLine("Sum is "+ Stack.PopValue("p"))
     
    Sub Sum
      Stack.PushValue("p", Stack.PopValue("p")+Stack.PopValue("p"))
    EndSub

    I discovered it from a post on http://social.msdn.microsoft.com/Forums/en-US/8b995743-071a-4eb0-abe3-2d05de90c018/additional-small-basic-resources?forum=smallbasic  by Litdev and Pappa Lapub 

    Which has this link: https://duckduckgo.com/?q=spartaschools+Small+Basic+Notes

    Just type what your looking for, e.g. Small Basic or C#, into their search bar and all sorts of links pop up. There's links to free e-books but I had no luck on getting any.


    Saturday, January 11, 2014 1:16 AM
    Moderator
  • Is there a way to pass parameters to a subroutine in small basic?

    Small basic language doesn’t support parameters in the case of subroutines.

    And how about LitDev Ext - LDCall.:

    Val1 = 45
    Val2 = 55

    args = ""
    TextWindow.WriteLine("Sum is "+ LDCall.Function2("Sum",Val1,Val2))
    return = ""

    Sub Sum
      return = args[1] + args[2]
    EndSub

    PS: Just type what your looking for, e.g.

    JJ, if you're talkin bout search bar on DDGo, thats default look of all search machines, i think ;-) DuckDuckGo is just another SAVER one, that does'nt track u an does'nt store your searches, clicks, behavoir and profile like big G and others, to cure Gphobia. (s. Startpage, Ixquick, Ecosia...)

    Saturday, January 11, 2014 3:08 AM
    Answerer
  • GraphicsWindow.DrawImage("http://images.yourdictionary.com/images/4200.16.treble-clef.jpg",0,0)

    :lol:

    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Saturday, January 11, 2014 3:26 AM
    Answerer
  • I have An Idea for a future challenge:

    write a program in which the user will draw something with his mouse. then, when he inputs that he is done, the program will replay in real time what the user drew.


    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Saturday, January 11, 2014 3:34 AM
    Answerer
  • Hey good idea - a real time draw.

    Saturday, January 11, 2014 7:46 AM
    Moderator
  • @ Zocks clef draw: 2 * (01001000 01100001)

    :)
    Sunday, January 12, 2014 6:42 AM
    Moderator
  • This is my sample for community suggestion by Nonki 2: JCC750.

    Screen shot of a program Chord Wave Form 0.1


    Nonki Takahashi

    Sunday, January 12, 2014 2:53 PM
    Moderator
  • I uploaded a program for text challenge: FCR130.
    Remove comment for File operation and run in local.

    Sums filename? sums.txt
    25+3=28
    15.7*91=1428.7
    -12-8=-20
    sqrt(81)=9
    5+sqrt(9)=8
    (7+5)/4=3
    Sum=1456.7
    Press any key to continue...

    Nonki Takahashi

    Wednesday, January 15, 2014 3:34 AM
    Moderator
  • These are my ideas for a future challenge.

    1. Make a tr (UNIX-like translate) command.
    2. Draw a Bezier or spline curve.
    3. Measure pixel width of a text in GraphicsWindow.

    Nonki Takahashi

    Wednesday, January 15, 2014 5:45 AM
    Moderator
  • Any/all GW challenges:

    This is my build so far for an extensible drop down menu for future GW programs. It's a clone of MS calculator menu. It's for my reusable code library.

    It's optimised quite a bit and is built into a game/event loop. The frame rate begins to drag at about 300fps.

    Menu items are easily changed/added/removed and I'll include an update for gw in the loop for switching screen sizes.

    TODO: is add the sub menus and set the menu calls. Different routines can then be attached to the menu calls.

    Any fb or tips always appreciated. I love EDP.

    VST735-0


    Thursday, January 16, 2014 9:14 PM
    Moderator
  • Jibba Jabba,

    Good try.

    Do you know resource file?  Menu items are defined in resource file for Windows application.  I think this will be your hint how do you have the menu information.

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa381045(v=vs.85).aspx


    Nonki Takahashi

    Monday, January 20, 2014 1:55 PM
    Moderator
  • @ Zocks clef draw: 2 * (01001000 01100001)

    :)

    01001001 01110100 00100000 01110100 01101111 01101111 01101011 00100000 01101101 01100101 00100000 01100001 00100000 01110011 01100101 01100011 00100000 01110100 01101111 00100000 01100111 01100101 01110100 00100000 01110111 01101000 01100001 01110100 00100000 01111001 01101111 01110101 00100000 01101101 01100101 01100001 01101110 01110100

    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Monday, January 20, 2014 3:38 PM
    Answerer
  • Hi Nonki, thanks for fb and sample resource.

    I've just finished 2 improvements to the "menu".

    1. It now has only 1 shape/sprite for the focus, which has paved the way to have just 1 shape for the "subMenu" focus.
    2. And now menuTitles can be of any length :)

     It's adaptive for event loop/game loop programs. All the programmer has to do is edit these 2 arrays to customise the "menu" (menuBar only): They plug-in the data run it and fudge the menuWidths. I've tested this adaptive part and it's quick to do and everything adjusts accurately. The same will apply to "subMenu"

    menu = "1=View Screen;2=Program;3=Help;4=Test This;5=Add Another Menu" ;6=;7= etc
    menuWidth = "1=105;2=85;3=55;4=85;5=150" 

    "isMenuSelected" & "menuFocusedOn = I" will open/close and change the subMenu in a cloned way the MS calculator does.

    "isSubMenuSelected & subMenuFocusedOn =subMenu[I] " will identify the menuItem and update the program state.

    I'll eventually put the menu updates into subroutines.  VST735-1


    Monday, January 20, 2014 11:27 PM
    Moderator
  • My solution to a Graphical Challenge - Simple calculator: BNF004.
    Tuesday, January 21, 2014 9:38 AM
  • My solution to a Graphical Challenge - Simple calculator: FKW094 even better .. without the typo.
    Tuesday, January 21, 2014 9:58 AM
  • Nice job Unstoppable_1

    I didn't see the typo the first time, but good to fix.

    Tuesday, January 21, 2014 10:04 AM
    Moderator
  • My solution to

    Curriculum Challenges 3.1

    1. Write a subroutine that can be called to welcome a user and tell them how long it was since they last started SmallBasic - Hint store the last time in a file in the current Program.Directory.

    FQG186


    Saturday, January 25, 2014 3:18 AM
    Moderator
  • I just realised I made a potentially dangerous error in the above sample. No file write error check.

    FQG186-0

    Sub DumpData
      If File.ReadContents(settingsPath) = "" Then 
        dumped[1] = File.WriteContents(settingsPath, "Tag=Created;" + log)
        dumped[2] = File.WriteLine(dataPath, 1, "Tag=Created;" + log)   
      EndIf
      dumped[3] = File.WriteLine(settingsPath, 2, "Tag=Accessed;" + log)
      dumped[4] = File.AppendContents(dataPath, "Tag=Accessed;" + log)  
      
      If Array.ContainsValue(dumped, "FAILURE") Then
        TextWindow.WriteLine("FAILURE")
      EndIf  
    EndSub

    Saturday, January 25, 2014 6:19 AM
    Moderator
  • Here is a submission for 3.1... sort of.

    I kind of got carried away with the second part and never worked on the other two. :-)

    Import code: ZZP714

    This will list the full contents of the folder structure from the current path downward. Changing the variable "followSubFolders" to False will tell the program to stay in the current folder.

    Enjoy!!!

    'File lister -- Compliments CodingCat aka Matthew L. Parets
    'Import Code: ZZP714
    
    'Open the window, add the controls
    GraphicsWindow.Title = "Directory List"
    GraphicsWindow.BrushColor = "black"
    GraphicsWindow.BackgroundColor = GraphicsWindow.GetColorFromRGB(255,255,200)
    folderTextBox = Controls.AddTextBox(60,10)
    Controls.SetSize(folderTextBox,495,25)
    Controls.SetTextBoxText(folderTextBox,program.Directory)
    GraphicsWindow.DrawText(10,15,"Folder:")
    goButton = Controls.AddButton("Go", 560,10)
    Controls.SetSize(goButton,55,25)
    filesTextBox = Controls.AddMultiLineTextBox(10,45)
    Controls.SetSize(filesTextBox,600,375)
    
    'Set the event to receive the button click
    Controls.ButtonClicked = whenGoClicked
    followSubFolders = "True"
    
    'Button Click Event
    Sub whenGoClicked
      If processingButton <> "true" Then 'Prevent a double click
        processingButton = "true"
        checkFolder = Controls.GetTextBoxText(folderTextBox) 'Get the folder and check for proper format
        If Text.GetSubTextToEnd(checkFolder, Text.GetLength(checkFolder)) <> "\" then
          checkFolder = checkFolder + "\"
        EndIf
        folder = checkFolder
        
        'Let the user know this may take a while
        boxContents = "Scanning: " + folder + Text.GetCharacter(13) + Text.GetCharacter(9)
        Controls.SetTextBoxText(filesTextBox, boxContents)
        
        scanPath()
        processingButton = "false"
      EndIf
    EndSub
    
    'Scan a given folder - Recurse into subfolders if requested
    Sub scanPath
      folderCount = 0
      fileCount = 0
      
      path = ""
      Stack.PushValue(path, folder)
      boxContents = ""
      While Stack.GetCount(path) > 0
        nextFolder = Stack.PopValue(path)
        slashText = nextFolder
        SlashOut()
        slashText = "..\" + slashText 
        boxContents = boxContents + Text.GetCharacter(13) + slashText
        
        filelist = file.GetFiles(nextfolder)
        holdForFileDisplay = ""
        filesInFolder = 0
        For i = 1 To Array.GetItemCount(fileList)
          slashText = fileList[i]
          SlashOut()
          
          slashText = "     " + slashText
          slashText = Text.GetCharacter(9) + slashText
          
          holdForFileDisplay = holdForFileDisplay + Text.GetCharacter(13)  + slashText
          fileCount = fileCount + 1
          filesInFolder = filesInFolder + 1
        EndFor
        
        boxContents = boxContents + " -- Files Stats: " + filesInFolder
        folderCount = folderCount + 1
        boxContents = boxContents + holdForFileDisplay
        
        If followSubFolders Then
          folderList = File.GetDirectories(nextFolder)
          For i = 1 To Array.GetItemCount(folderList)
            Stack.PushValue(path, folderList[i])
          EndFor
        EndIf
        
        GraphicsWindow.Title = "Directory List -- " + Stack.GetCount(path) + " -- " + nextFolder
      EndWhile
      
      'Add Stats -- Added to text box buffer backwards to place it at the top of the list
      boxContents = "    Folders: " + folderCount + " - Files: " + fileCount + Text.GetCharacter(13) +  boxContents
      boxContents = "Contents of " + folder +  boxContents
      If followSubFolders Then
        boxContents = " (plus sub folders)" +  boxContents
      EndIf
      boxContents = Text.GetCharacter(13) +  boxContents
      
      Controls.SetTextBoxText(filesTextBox, boxContents) 'Update the window
      GraphicsWindow.Title = "Directory List"
    EndSub
    
    'Pull the text out from the last part of the text (after the last slash)
    Sub SlashOut
      slashLoc = Text.GetIndexOf(slashText,"\")
      While slashLoc <> 0
        slashText = Text.GetSubTextToEnd(slashText, slashLoc+1)
        slashLoc = Text.GetIndexOf(slashText,"\")
      EndWhile
    EndSub
    


    • Edited by Coding CatEditor Wednesday, January 29, 2014 9:21 PM copy and paste error
    Wednesday, January 29, 2014 9:20 PM
    Answerer