Ok, anyway if you want to continue having the advantage of using Functions, you can switch to using pointers. It is not difficult, it is just getting used to the fact that the first element of the string is not zero, the first element is now the memory address of the first element and to access the memory addresses a command or a function is used.
I leave the example:
'Amicus18
'***********************************************************************
'Match function
'Pic18F26k22, OshonSoft Pic18 Basic Compiler v5.17
'***********************************************************************
#define CLOCK_FREQUENCY = 64 'Clock 64Mhz
#define STRING_MAX_LENGTH = 100
#define SINGLE_DECIMAL_PLACES = 1
'#define SIMULATION_WAITMS_VALUE = 1
'***********************************************************************
'***********************************************************************
'Include "_FuncionesPic18F26K22.bas"
'Include "_SetUpAmicus18.bas"
'Include "_FuncionesTmrBase.bas"
'Include "_FuncionesUartRingBuffer.bas"
'Include "_Funciones_Buffer_RS232.Bas"
'***********************************************************************
main:
'********************************************************************
UART1_Init 115200
'UART2_Init 4800
WaitMs 1
Dim String1 As String
Dim P_String1 As Word
Dim String2 As String
Dim P_String2 As Word
'Pointer assignment up to 12bit for Pic18 series
Dim _Address As Word
Symbol _Address_HB = _Address.HB
Symbol _Address_LB = _Address.LB
ASM: LFSR 2,String1
ASM: MOVFW FSR2H
ASM: MOVWF _Address_HB
ASM: MOVFW FSR2L
ASM: MOVWF _Address_LB
P_String1 = _Address '-> String1 (Array)
'Pointer assignment up to 12bit for Pic18 series
ASM: LFSR 2,String2
ASM: MOVFW FSR2H
ASM: MOVWF _Address_HB
ASM: MOVFW FSR2L
ASM: MOVWF _Address_LB
P_String2 = _Address '-> String2 (Array)
String1 = "$GNRMC,000000.00,A,3723.02837,N,00150.39853,W,0.820,188.36,110706,,,A*74"
String2 = "GNRMC"
While True
'UART_Write #match(String1, 1, String2), CrLf
If match(P_String1, 1, P_String2) > 0 Then
UART_Write "Ok"
Else
UART_Write "No Match"
Endif
While True
Wend
Wend
End
'The corresponding match function
Function match(input_str As Word, str_ix As Byte, match_str As Word) As Byte ' these variable names can be changes as wished
Symbol _Return = match
Symbol position_counter = input_str
Symbol shortposition = match_str
position_counter = input_str + str_ix
While Peek(shortposition) > 0
If Peek(position_counter) = Peek1(shortposition) Then
_Return = 1 'set the match indicator to valid
shortposition++ 'increment the short string position counter
Else
_Return = 0 'set the match indicator To Not valid
Exit 'jump out of the function
Endif
position_counter++
Wend
End Function 'the corresponding match function
'*******************************************************************************************
'Peek function of the traditional Basic language to work with memory addresses (read).
'*******************************************************************************************
'Returns the value (Byte) containing the specified memory address (Word).
'It can be used in compound conditional structures and mathematical operations.
'For example: If Peek(_Address) > 0 And PeeK(_Address + 1) = 0.
'Restrictions until v5.17 (PSI 18): cannot be used in simple conditionals with itselfs.
'For example: If Peek(_Address) = PeeK(_Address +1) -> in this type or similar (And, Or)
'always returns true.
'Bypassing restrictions: If Peek(_Address) = Peek1(_Address +1)
'********************************************************************************************
'Peek
Function Peek(_Address As Word) As Byte
Symbol _Return = Peek
_Return = Pointer(_Address)
End Function
'Peek1
Function Peek1(_Address As Word) As Byte
Symbol _Return = Peek1
_Return = Pointer(_Address)
End Function