What am I doing wrong with this class?

netchicken

Active Member
Licensed User
Longtime User
I have been creating a class and am unable to get an output from it.

Log(match.process) throws an error Log(match.process) Word: ) I think its the connection with Public Sub process(matchedname As String) thats wrong.


Data going in is sms number received (From), number from contacts, and name from contacts. It returns the name if it matches.

B4X:
'Class module
'I want to put the numbers and name in, strip them back, compare them and get out the matched name

Sub Class_Globals
'internal _private variables
Private From As String   
Private contactnumber As String
Private name As String
End Sub


'data goes in through afrom and acontact to from and contactnumber
Sub Initialize(afrom As String, acontact As String, aname As String)
From = afrom
contactnumber = acontact
name = aname
End Sub

'matchedname comes out if true
Public Sub process(matchedname As String)
From = From.SubString2(From.Length-7, From.Length)
contactnumber = contactnumber.SubString2(contactnumber.Length-7, contactnumber.Length)

If From = contactnumber Then
Return matchedname = name

Log("matched number")

End If
End Sub

In my main code I have just added the new section inside an existing sub that works, its just stuck into the middle.
B4X:
Sub smscopy
'Load a phone number From from the stored number we saved in getcontacts. This is to simulate using the SMS reciever in the service module later.
Dim From As String
From = File.ReadString(File.DirInternal, "from.txt")
From = From.SubString2(From.Length-7, From.Length)
'Log("from = " & From)

'strings to hold the phone number and the name
Dim PhoneNum, phoneDispname As String
'iterate though the list of KEYS and VALUES
For x=0 To mastermapnames.Size-1
'Get out the phone number at each x pair
 PhoneNum = mastermapnames.GetkeyAt(x) 
 'Get out the Name at each x pair
  phoneDispname = mastermapnames.GetValueAt(x)
  'trim any spaces off the name
  phoneDispname = phoneDispname.Trim 



'NEW CLASS ADDED IN 
  Dim match As matchednumber
  match.Initialize(From, PhoneNum, phoneDispname)
' Log(match.process())
'END CLASS

Anyone haven an idea?
 
Last edited:
Top