Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim StrToHash As EditText
Dim HashOfStr As Label
Dim HashMe As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
StrToHash.Initialize("")
HashOfStr.Initialize("")
HashMe.Initialize("HashMe")
HashMe.Text = "Hash Me!"
HashOfStr.TextSize = 14
Activity.AddView(StrToHash,5,5,250,50)
Activity.AddView(HashMe,5,60,100,40)
Activity.AddView(HashOfStr,5,120,250,40)
End Sub
Sub HashMe_Click
Dim HashValue As Long
HashValue = Generate_Hash(StrToHash)
HashOfStr.Text = HashValue
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Generate_Hash(Hashit As String)
Dim Prime As Long : Prime = 1125899906842597
Dim cntr As Int
Dim ReturnHash As Long
Dim c As Char
For cntr = 0 To Hashit.Length - 1
ReturnHash = 31*Prime + Asc(Hashit.CharAt(cntr))
Next
Return ReturnHash
End Sub