Sub Process_Globals
Dim AppId, ClientKey As String
AppId = "YourAppId"
ClientKey = "YoudClientKey"
Dim Parse As Parse
Dim NumberOfScores As Int
NumberOfScores=10
Dim LowestScore As Int
Dim lstHighScore As List
Dim Timer1 As Timer
Dim counter As Int
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Parse.Initialize(AppId, ClientKey)
End If
ResetScores
Activity.AddMenuItem("Add 5 records", "Add5Items")
Activity.AddMenuItem("Show High Records", "ShowHR")
End Sub
Sub Add5Items_click
counter=0
Timer1.Initialize("Timer1",2000)
Timer1.Enabled=True
End Sub
Sub ShowHR_click
LogScores
End Sub
Sub Timer1_tick
counter=counter+1
Timer1.Enabled=False
AddScore(("Name"&Rnd(1,100)),Rnd(1,1000))
If counter<=4 Then
Timer1.Initialize("Timer1",2000)
Timer1.Enabled=True
Else
Timer1.Enabled=False
Log("---------- Added 5 records ----------")
End If
End Sub
Sub AddScore(strName As String, intScore As Int)
Log("*** Adding score "&strName&" -> "&intScore &" ***")
Dim po2 As ParseObject
po2.Initialize("HighScores")
po2.Put("Name", strName) ' after we add the new value
po2.Put("Score", IntScore)
po2.Save("po2")
ProgressDialogShow("Saving.")
End Sub
Sub po2_DoneSave (Success As Boolean)
ProgressDialogHide
If Success = False Then
Log(LastException.Message)
End If
End Sub
Sub LogScores
Dim query As ParseQuery
query.Initialize("HighScores")
query.OrderBy("Score", False)
query.Find("query", 1)
ProgressDialogShow("Waiting for response.")
End Sub
Sub query_DoneFind (Success As Boolean, ListOfPO As List, TaskId As Int)
ProgressDialogHide
If Success = False Then
Log("Error: " & LastException.Message)
ToastMessageShow("Error: " & LastException.Message, True)
Else
Log("--------- TOP "&NumberOfScores&" HIGH SCORES ---------")
Dim K As Int
If NumberOfScores<ListOfPO.Size Then
K=NumberOfScores
Else
K=ListOfPO.Size
End If
For i = 0 To K-1
Dim po As ParseObject
po = ListOfPO.Get(i)
Log(" + "& po.GetString("Name") &" + "&po.GetInt("Score"))
Next
Log("--------------------------------------")
End If
End Sub
Sub ResetScores
Dim query As ParseQuery
query.Initialize("HighScores")
query.Find("DeleteItems", 1)
Log("All Rows Deleted...")
ProgressDialogShow("Waiting for response.")
End Sub
Sub DeleteItems_DoneFind (Success As Boolean, ListOfPO As List, TaskId As Int)
ProgressDialogHide
If Success = False Then
Log("Error: " & LastException.Message)
ToastMessageShow("Error: " & LastException.Message, True)
Else
For i = 0 To ListOfPO.Size - 1
Dim po As ParseObject
po = ListOfPO.Get(i)
po.Delete("delete")
ProgressDialogShow("Waiting for response.")
Next
End If
End Sub
Sub Delete_DoneDelete (Success As Boolean)
ProgressDialogHide
Dim po As ParseObject
po = Sender
Log(po.ObjectId & " delete, success = " & Success)
End Sub
Sub Activity_Pause(UserClosed As Boolean)
End Sub
Sub Activity_Resume
End Sub