Hello
I had this code, it basically fetches usergroups from a platform (mInformat.GetClasses()) and pushes them to our Google Workspace. It works perfectly.:
But now I want to extend this code and create users. But ofcourse, the group creation must be finished before trying to add users to groups.
Now, I wanted to solve this easily, so I created a resumable Sub "CreateGroups" and call it with Wait For in Start, and create another method "CreateUsers" right underneath it.
Now nothing works. And the odd thing is, Sub CreateGroups is throwing a warning that it's not used, yet I'm calling it with the Wait For in the Start sub.
I was thinking I did something stupid with the StartMessageLoop again, altough it shouldn't be, as the Wait For in the Start method should create a return and go to the StartMessageLoop line as just before.
Everytime I think I really grasp Wait Fors, I still manage to do something wrong
Can anyone point me to my obvious mistake? Why is the Sub CreateGroups not called with this line:
Thanks for any help or guidance!
I had this code, it basically fetches usergroups from a platform (mInformat.GetClasses()) and pushes them to our Google Workspace. It works perfectly.:
B4X:
Sub AppStart (Args() As String)
mInformat.Initialize()
Start
StartMessageLoop
End Sub
Sub Start()
Wait For(mInformat.GetClasses()) Complete (ClassMap As Map)
For Each classCode As String In ClassMap.Keys
Dim sClass As StudentClass = ClassMap.Get(classCode)
Wait For(Google.GroupExists(sClass.Email)) Complete (GroupExists As Boolean)
If GroupExists = False Then
Google.CreateGroup(sClass.Email, sClass.Classcode, "Generated by ITG on " & DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now))
Log("Created " & sClass.Classcode)
Else
Log(sClass.Classcode & " already exists.")
End If
Next
End Sub
But now I want to extend this code and create users. But ofcourse, the group creation must be finished before trying to add users to groups.
Now, I wanted to solve this easily, so I created a resumable Sub "CreateGroups" and call it with Wait For in Start, and create another method "CreateUsers" right underneath it.
B4X:
Sub AppStart (Args() As String)
mInformat.Initialize()
Start
StartMessageLoop
End Sub
Sub Start()
Wait For CreateGroups
End Sub
Sub CreateGroups
Wait For(mInformat.GetClasses()) Complete (ClassMap As Map)
For Each classCode As String In ClassMap.Keys
Dim sClass As StudentClass = ClassMap.Get(classCode)
Wait For(Google.GroupExists(sClass.Email)) Complete (GroupExists As Boolean)
If GroupExists = False Then
Google.CreateGroup(sClass.Email, sClass.Classcode, "Generated by ITG on " & DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now))
Log("Created " & sClass.Classcode)
Else
Log(sClass.Classcode & " already exists.")
End If
Next
End Sub
Now nothing works. And the odd thing is, Sub CreateGroups is throwing a warning that it's not used, yet I'm calling it with the Wait For in the Start sub.
I was thinking I did something stupid with the StartMessageLoop again, altough it shouldn't be, as the Wait For in the Start method should create a return and go to the StartMessageLoop line as just before.
Everytime I think I really grasp Wait Fors, I still manage to do something wrong
Can anyone point me to my obvious mistake? Why is the Sub CreateGroups not called with this line:
Wait For CreateGroups
Thanks for any help or guidance!