I am not recieving any errors, but the program is not doing what I had expected. I wish to make a program that randomly takes characters (well, not completely randomly. I used the table of letter frequency from wikipedia andincluded that data in my program by figuring out the max for the random numbers from the percentages in the wikipedia chart.) and adds them to a long list of characters ands saves the file every 5 minutes.I have calculated the timer interval so that the number of miliseconds shown is equal to 5 minutes. I am getting the textwindow, and it is showing (rather rapidly, as I need it to be) a long random list of characters (including spaces). The problems are (A) I am having difficulty saving the text as a file. You'll find the code that is supposed to do that at the bottom. The other problem I am having is once so many characters are added, the ones at the top start disappearing. I would scroll to the top, and each time I did so the letters at the top had changed (this is all during the same test), but I need all characters to be stored when the file saves. Granted, I haven't actually seen one of the saved files as I have not figured out how to make that work. One other thing, not sure if it's important, I haven't run a published version yet. I've only been running the debug builds. Does that affect how it handles actions with files? I could really use advice, as I'm pretty new to programming. The entire code is below.
Module RandomModule
Dim X, Y, contents As Primitive
Sub Main()
X = 1
Y = 1
While X = Y
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(12) = 1 Then
TextWindow.Write("A")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(67) = 1 Then
TextWindow.Write("B")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(36) = 1 Then
TextWindow.Write("C")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(24) = 1 Then
TextWindow.Write("D")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(8) = 1 Then
TextWindow.Write("E")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(45) = 1 Then
TextWindow.Write("F")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(50) = 1 Then
TextWindow.Write("G")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(16) = 1 Then
TextWindow.Write("H")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(14) = 1 Then
TextWindow.Write("I")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(654) = 1 Then
TextWindow.Write("J")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(130) = 1 Then
TextWindow.Write("K")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(25) = 1 Then
TextWindow.Write("L")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(42) = 1 Then
TextWindow.Write("M")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(15) = 1 Then
TextWindow.Write("N")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(13) = 1 Then
TextWindow.Write("O")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(52) = 1 Then
TextWindow.Write("P")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(1053) = 1 Then
TextWindow.Write("Q")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(17) = 1 Then
TextWindow.Write("R")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(16) = 1 Then
TextWindow.Write("S")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(11) = 1 Then
TextWindow.Write("T")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(36) = 1 Then
TextWindow.Write("U")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(101) = 1 Then
TextWindow.Write("V")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(42) = 1 Then
TextWindow.Write("W")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(667) = 1 Then
TextWindow.Write("X")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(51) = 1 Then
TextWindow.Write("Y")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(1351) = 1 Then
TextWindow.Write("Z")
End If
If Microsoft.SmallBasic.Library.Math.GetRandomNumber(6) = 1 Then
TextWindow.Write(" ")
End If
End While
Timer.Interval = 18000000
AddHandler Timer.Tick, AddressOf Time
End Sub
Sub Time()
X = X + 1
contents = TextWindow.Read()
File.AppendContents("c:\random\test.txt", contents)
TextWindow.Clear()
Y = Y + 1
End Sub
End Module