DogFlu66
Member
Hello; for those who need or want to experiment with lists, I leave you some libraries.
With these libraries it is possible to simulate small databases, with all its elements for its control, such as creation, search, substitution, deletion of records, etc.
For example: by adding a small menu (display and keyboard) you can manage the list of telephone numbers for access control with a garage door by adding the control of a gsm module, or also with radio modules.
To work with lists efficiently you need to use pointers. So I leave in the example how to get the memory address of a variable at runtime.
For any questions you can ask.
With these libraries it is possible to simulate small databases, with all its elements for its control, such as creation, search, substitution, deletion of records, etc.
For example: by adding a small menu (display and keyboard) you can manage the list of telephone numbers for access control with a garage door by adding the control of a gsm module, or also with radio modules.
To work with lists efficiently you need to use pointers. So I leave in the example how to get the memory address of a variable at runtime.
For any questions you can ask.
Code:
'************************************************
'Working with list.
'Assignment of pointers to variables.
'12/01/2023, By COS, PSI V4.34.
'************************************************
Include "_FuncionesListas.bas"
'String Variables.
Dim m1 As String
Dim m2 As String
Dim m3 As String
Dim m4 As String
'Declares vector of vectors (list).
Dim m0(51) As Byte
'Pointer variables, two bytes long.
Dim p_m0 As Word
Dim p_m1 As Word
Dim p_m2 As Word
Dim p_m3 As Word
Dim p_m4 As Word
'Aux. variables.
Dim n0 As Byte
Dim n1 As Byte
Dim n2 As Byte
Dim n3 As Byte
Dim n4 As Byte
Dim p_aux As Word
'Assign values.
m1 = "0123456789"
m2 = "9876543210"
m3 = "ABCDE"
m4 = "FGHIJKLMN"
'Pointer:
Dim _ADDRESS As Word 'Variable de paso
Symbol _Address_HB = _ADDRESS.HB
Symbol _Address_LB = _ADDRESS.LB
'Pointer assignment.
ASM: LFSR 2,m0
ASM: MOVFW FSR2H
ASM: MOVWF _Address_HB
ASM: MOVFW FSR2L
ASM: MOVWF _Address_LB
p_m0 = _ADDRESS
'Asignación puntero
ASM: LFSR 2,m1
ASM: MOVFW FSR2H
ASM: MOVWF _Address_HB
ASM: MOVFW FSR2L
ASM: MOVWF _Address_LB
p_m1 = _ADDRESS
'Asignación puntero
ASM: LFSR 2,m2
ASM: MOVFW FSR2H
ASM: MOVWF _Address_HB
ASM: MOVFW FSR2L
ASM: MOVWF _Address_LB
p_m2 = _ADDRESS
'Asignación puntero
ASM: LFSR 2,m3
ASM: MOVFW FSR2H
ASM: MOVWF _Address_HB
ASM: MOVFW FSR2L
ASM: MOVWF _Address_LB
p_m3 = _ADDRESS
'Asignación puntero
ASM: LFSR 2,m4
ASM: MOVFW FSR2H
ASM: MOVWF _Address_HB
ASM: MOVFW FSR2L
ASM: MOVWF _Address_LB
p_m4 = _ADDRESS
'*************************************************
Call _vstrformat(p_m0, 51) 'Format the list.
n0 = _vstrlong(p_m0) 'Number of ascii characters that the list can contain.
n1 = _vstrfree(p_m0) 'Number of free characters.
Call _vstradd(p_m0, p_m1) 'Add string
Call _vstradd(p_m0, p_m2) 'Add string
Call _vstradd(p_m0, p_m3) 'Add string
Call _vstradd(p_m0, p_m4) 'Add string
n3 = _vstrlong(p_m0) 'List lengts.
n4 = _vstrfree(p_m0) 'Number of free characters.
p_aux = _vstrcmp2(p_m0, p_m2) 'Search string
If p_aux > 0 Then Call _vstrsub(p_aux) 'Delete string and update list.
End
Attachments
Last edited: