While "True"
selectButtonInMainMenu()
recordContent()
playRecording()
recordData()
returnToMainMenu() 'Placement: Always have means return to main menu
Program.Delay(50) 'Sleep
EndWhile
For i = 3 To 0 Step -1
button[i] = Controls.AddButton(buttonName[i],mainMenuButtonsX-(mainMenuButtonsWidth*i),mainMenuButtonsY)
Controls.SetSize(button[i],mainMenuButtonsWidth,mainMenuButtonsHeight)
EndFor
Sub recordContent
inputTextInTextBox = "False" 'Prevents statement on line 112 from becoming true w/out user input
startRecording = Clock.ElapsedMilliSeconds 'For accuracy, must be placed immediately before recording begins
While currentState = "recording"
If (inputTextInTextBox = "True") Then
record[nextRecord]["time"] = Clock.ElapsedMilliseconds - startRecording
record[nextRecord]["text"] = Controls.GetTextBoxText(mainMenuTextBox)
nextRecord = nextRecord + 1
inputTextInTextBox = "False" 'Prevent code block from repeating
EndIf
returnToMainMenu()
lastClicked = "" 'returnToMainMenu() sub in main loop becomes false & prevent minor flicker
Program.Delay(20) 'Sleep
EndWhile
EndSub
Sub playRecording
recordCount = Array.GetItemCount(record) 'length of recording
startReplay = Clock.ElapsedMilliseconds 'For accuracy, must be placed immediately before recording starts
While nextRecord < recordCount And currentstate = "playing" 'playing prevent infinite loop
elapsed = Clock.ElapsedMilliseconds - startReplay
While record[nextRecord]["time"] <= elapsed And currentState = "playing" 'playing prevent infinite loop
Controls.SetTextBoxText(mainMenuTextBox,record[nextRecord]["text"])
nextRecord = nextRecord + 1
If (nextRecord >= recordCount) Then
currentState = "done"
Shapes.SetText(mess,setMess + textDisplayOfPlayState[currentState])
EndIf
returnToMainMenu() 'Can exit loop prematurely
EndWhile
returnToMainMenu() 'Can exit loop prematurely
Program.Delay(50) 'Sleep & recreate key stroke interval w/ a difference of 50 milSec or less
EndWhile
EndSub
Sub recordData
While currentState = "saving" Or currentState = "opening"
If (lastClicked = "Save" Or lastClicked = "Open") Then
retrieveRecordFileName = Controls.GetTextBoxText(subMenuFileTextBox)
recordFileName = Text.Append("\",retrieveRecordFileName)
If (lastClicked = "Save") Then
' The following line could be harmful and has been automatically commented.
' File.WriteContents(pre+recordFileName+ext,record) 'Saved same location as small basic programs
ElseIf (lastClicked = "Open") Then
' The following line could be harmful and has been automatically commented.
' record = File.ReadContents(pre+recordFileName+ext)
EndIf
lastClicked = "Back"
EndIf
returnToMainMenu()
lastClicked = "" 'returnToMainMenu() sub in main loop becomes false & prevent minor flicker
Program.Delay(50) 'Sleep
EndWhile
EndSub
Sub returnToMainMenu
If (lastClicked = "Back" Or lastClicked = "Stop") Then
createMainMenu()
EndIf
EndSub
Sub onButtonClicked
lastClicked = Controls.GetButtonCaption(Controls.LastClickedButton)
EndSub
Sub onTextTypedInTextBox
inputTextInTextBox = "True"
EndSub