Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Database simulation (OshonSoft Basic).

DogFlu66

Member
Note: The final library can be downloaded in response 20 of this thread.

Hello; I have been converting an old door opener program by telephone touch (phone call) to this language.

Not having a function in the language that allows me to associate data, I have written a library to simulate the use of registers and fields.

I thought it would be very complex to do, but it is actually very simple and is done with a couple of very simple functions and with hardly any code in them.

I leave the example for those who want to play with them for a while in the environment simulator:

'***********************************************************************
'Experimental functions for simulate registers with fields.
'Pic18F26k22, OshonSoft Pic18 Basic Compiler v5.33
'By COS, 2024/02/24
'***********************************************************************
'Phone list:
'Fields: Name, Phone and Date.
'Length of fields equal to 10 characters.
'***********************************************************************
#define CLOCK_FREQUENCY = 64 'Clock 64Mhz
#define STRING_MAX_LENGTH = 12
'#define SIMULATION_WAITMS_VALUE = 1
'***********************************************************************
'***********************************************************************
main:
UART1_Init 115200
'UART2_Init 4800
'WaitMs 1

Dim _String[10] As String 'Auxiliary variable for data exchange.
Dim x As Byte

'Initializes the list vector.
Call _Pointer0(P_List)
Format_List(P_List)

'Write field (write registers)
Write_List("Peter", Name, 0, P_List) 'Reg (0,0)
Write_List("600000001", Phone, 0, P_List) 'Reg (0,1)
Write_List("2024/02/25", Date, 0, P_List) 'Reg (0,2)

Write_List("John", Name, 1, P_List) 'Reg (1,0)
Write_List("600000002", Phone, 1, P_List) 'Reg (1,1)
Write_List("2024/02/26", Date, 1, P_List) 'Reg (1,2)

Write_List("George", Name, 2, P_List) 'Reg (2,0)
Write_List("600000003", Phone, 2, P_List) 'Reg (2,1)
Write_List("2024/02/27", Date, 2, P_List) 'Reg (2,2)

UART_Write "Registers with three fields", CrLf
UART_Write "---------------------------", CrLf, CrLf

'Extract field (read registers).
For x = 0 To 9 'Registers
UART_Write "Reg: ",#x, CrLf

_String = Read_List(Name, x, P_List)
UART_Write "Field 0 (Name): ", _String, CrLf

_String = Read_List(Phone, x, P_List)
UART_Write "Field 1 (Phone): ", _String, CrLf

_String = Read_List(Date, x, P_List)
UART_Write "Field 2 (Date): ", _String, CrLf

UART_Write "---------------------------", CrLf
Next x
UART_Write "End", CrLf

End
'From here, export the code as a library.

'*************************************************************************
'* Functions To simplify working with lists or small database simulation *
'* By COS, 20240225, OshonSoft Pic18 v5.33 *
'*************************************************************************

'*****************************************************************************************
'For two fields per register.
'*****************************************************************************************
'Declares the elements necessary to form the list [Name, Phone].
//Const nFields = 2 'Number of fields per register.
//Const FieldLength = 10 'Field length
//Const nRegisters = 20 'Number of registers = nReg * nField
//Dim List(200) As Byte 'Vector length equals nReg * FieldLength
'Dim _String[10] As String 'Auxiliary variable for data exchange.
//Const Name = 0 'To select the Name field.
//Const Phone = 1 'To select the Phone field.
'*****************************************************************************************

'*****************************************************************************************
'For three fields per register.
'*****************************************************************************************
'Declares the elements necessary to form the list [Name, Phone, Date].
Const nFields = 3 'Number of fields per register.
Const FieldLength = 10 'Field length
Const nRegisters = 30 'Number of registers = nReg * nField
Dim List(300) As Byte 'Vector length equals nReg * FieldLength
'Dim _String[10] As String 'Auxiliary variable for data exchange.
Const Name = 0 'To select the Name field.
Const Phone = 1 'To select the Phone field.
Const Date = 2 'To select the Date field.
'*****************************************************************************************
'Pointer
Dim P_List As Word 'It will contain the address of then firs element of the list vector.
Symbol _p0 = List 'Indicates the vector to use as a list.

'******************************************************************************************************
'In the Main: to initialize the list.
'Call _Pointer0(P_List) 'Call from main to assign the address of the vector before using the functions.
'Format_List(P_List) 'Call function to start the list once you know the address.
'******************************************************************************************************

'Pointer assignment for Pic18 series.
Proc _Pointer0(ByRef _p As Word)
Symbol _Return_HB = _p.HB
Symbol _Return_LB = _p.LB
ASM: LFSR 2, _p0
ASM: MOVFW FSR2H
ASM: MOVWF _Return_HB
ASM: MOVFW FSR2L
ASM: MOVWF _Return_LB
End Proc
'*************************************************
'Function to "Write" a field in a register
'*************************************************
'field: field on which work will be done.
'register: register on which work will be done.
'string_input: field to add to the list.
'p_array = Address of the first element of the list vector.
'Writes a copy of the input string to the requested field of the indicated register.
Function Write_List(string_input[10] As String, field As Word, register As Word, p_array As Word) As Word
Dim index As Word
Dim flag As Bit
flag = 0
'Calculates the address of the first element of the field.
p_array = field + (register * (FieldLength * nFields)) + (field * (FieldLength -1)) + p_array
For index = 0 To (FieldLength -1) 'Traverse the field using the index "x".
If string_input(x) = 0 Then flag = 1 'End of field mark
If flag = 0 Then
Pointer(index + p_array) = string_input(index) 'Write a copy in the indicated register field.
Else
Pointer(index + p_array) = 0 'Remove any unused characters from the field.
Endif
Next index
End Function
'*************************************************
'Function to "Read" a field in a register
'*************************************************
'field = field on which work will be done.
'register = register on which work will be done.
'p_array = Address of the first element of the list vector.
'The requested field is returned according to the input parameters.
Function Read_List(field As Word, register As Word, p_array As Word) As String
Symbol Return_String = Read_List 'Returns requested field.
Dim index As Word
'Calculates the address of the first element of the field.
p_array = field + (register * (FieldLength * nFields)) + (field * (FieldLength -1)) + p_array
For index = 0 To (FieldLength -1) 'Traverse the field using the index.
Return_String(index) = Pointer(index + p_array) 'makes a copy of the requested field.
Next index
End Function

DataBase_Output.jpg
 

Attachments

  • DataBase.bas
    7 KB · Views: 190
Last edited:
Hello; I have been converting an old door opener program by telephone touch (phone call) to this language.

Not having a function in the language that allows me to associate data, I have written a library to simulate the use of registers and fields.

I thought it would be very complex to do, but it is actually very simple and is done with a couple of very simple functions and with hardly any code in them.

I leave the example for those who want to play with them for a while in the environment simulator:

'***********************************************************************
'Experimental functions for simulate registers with fields.
'Pic18F26k22, OshonSoft Pic18 Basic Compiler v5.33
'By COS, 2024/02/24
'***********************************************************************
'Phone list:
'Fields: Name, Phone and Date.
'Length of fields equal to 10 characters.
'***********************************************************************
#define CLOCK_FREQUENCY = 64 'Clock 64Mhz
#define STRING_MAX_LENGTH = 12
'#define SIMULATION_WAITMS_VALUE = 1
'***********************************************************************
'***********************************************************************
main:
UART1_Init 115200
'UART2_Init 4800
'WaitMs 1

Dim _String[10] As String 'Auxiliary variable for data exchange.
Dim x As Byte

'Initializes the list vector.
Call _Pointer0(P_List)
Format_List(P_List)

'Write field (write registers)
Write_List("Peter", Name, 0, P_List) 'Reg (0,0)
Write_List("600000001", Phone, 0, P_List) 'Reg (0,1)
Write_List("2024/02/25", Date, 0, P_List) 'Reg (0,2)

Write_List("John", Name, 1, P_List) 'Reg (1,0)
Write_List("600000002", Phone, 1, P_List) 'Reg (1,1)
Write_List("2024/02/26", Date, 1, P_List) 'Reg (1,2)

Write_List("George", Name, 2, P_List) 'Reg (2,0)
Write_List("600000003", Phone, 2, P_List) 'Reg (2,1)
Write_List("2024/02/27", Date, 2, P_List) 'Reg (2,2)

UART_Write "Registers with three fields", CrLf
UART_Write "---------------------------", CrLf, CrLf

'Extract field (read registers).
For x = 0 To 9 'Registers
UART_Write "Reg: ",#x, CrLf

_String = Read_List(Name, x, P_List)
UART_Write "Field 0 (Name): ", _String, CrLf

_String = Read_List(Phone, x, P_List)
UART_Write "Field 1 (Phone): ", _String, CrLf

_String = Read_List(Date, x, P_List)
UART_Write "Field 2 (Date): ", _String, CrLf

UART_Write "---------------------------", CrLf
Next x
UART_Write "End", CrLf

End
'From here, export the code as a library.

'*************************************************************************
'* Functions To simplify working with lists or small database simulation *
'* By COS, 20240225, OshonSoft Pic18 v5.33 *
'*************************************************************************

'*****************************************************************************************
'For two fields per register.
'*****************************************************************************************
'Declares the elements necessary to form the list [Name, Phone].
//Const nFields = 2 'Number of fields per register.
//Const FieldLength = 10 'Field length
//Const nRegisters = 20 'Number of registers = nReg * nField
//Dim List(200) As Byte 'Vector length equals nReg * FieldLength
'Dim _String[10] As String 'Auxiliary variable for data exchange.
//Const Name = 0 'To select the Name field.
//Const Phone = 1 'To select the Phone field.
'*****************************************************************************************

'*****************************************************************************************
'For three fields per register.
'*****************************************************************************************
'Declares the elements necessary to form the list [Name, Phone, Date].
Const nFields = 3 'Number of fields per register.
Const FieldLength = 10 'Field length
Const nRegisters = 30 'Number of registers = nReg * nField
Dim List(300) As Byte 'Vector length equals nReg * FieldLength
'Dim _String[10] As String 'Auxiliary variable for data exchange.
Const Name = 0 'To select the Name field.
Const Phone = 1 'To select the Phone field.
Const Date = 2 'To select the Date field.
'*****************************************************************************************
'Pointer
Dim P_List As Word 'It will contain the address of then firs element of the list vector.
Symbol _p0 = List 'Indicates the vector to use as a list.

'******************************************************************************************************
'In the Main: to initialize the list.
'Call _Pointer0(P_List) 'Call from main to assign the address of the vector before using the functions.
'Format_List(P_List) 'Call function to start the list once you know the address.
'******************************************************************************************************

'Pointer assignment for Pic18 series.
Proc _Pointer0(ByRef _p As Word)
Symbol _Return_HB = _p.HB
Symbol _Return_LB = _p.LB
ASM: LFSR 2, _p0
ASM: MOVFW FSR2H
ASM: MOVWF _Return_HB
ASM: MOVFW FSR2L
ASM: MOVWF _Return_LB
End Proc
'*************************************************
'Function to "Write" a field in a register
'*************************************************
'field: field on which work will be done.
'register: register on which work will be done.
'string_input: field to add to the list.
'p_array = Address of the first element of the list vector.
'Writes a copy of the input string to the requested field of the indicated register.
Function Write_List(string_input[10] As String, field As Word, register As Word, p_array As Word) As Word
Dim index As Word
Dim flag As Bit
flag = 0
'Calculates the address of the first element of the field.
p_array = field + (register * (FieldLength * nFields)) + (field * (FieldLength -1)) + p_array
For index = 0 To (FieldLength -1) 'Traverse the field using the index "x".
If string_input(x) = 0 Then flag = 1 'End of field mark
If flag = 0 Then
Pointer(index + p_array) = string_input(index) 'Write a copy in the indicated register field.
Else
Pointer(index + p_array) = 0 'Remove any unused characters from the field.
Endif
Next index
End Function
'*************************************************
'Function to "Read" a field in a register
'*************************************************
'field = field on which work will be done.
'register = register on which work will be done.
'p_array = Address of the first element of the list vector.
'The requested field is returned according to the input parameters.
Function Read_List(field As Word, register As Word, p_array As Word) As String
Symbol Return_String = Read_List 'Returns requested field.
Dim index As Word
'Calculates the address of the first element of the field.
p_array = field + (register * (FieldLength * nFields)) + (field * (FieldLength -1)) + p_array
For index = 0 To (FieldLength -1) 'Traverse the field using the index.
Return_String(index) = Pointer(index + p_array) 'makes a copy of the requested field.
Next index
End Function

View attachment 144696
Hi D,
It worked first time. Is it for a phone number search, where the name is typed in?
C
 

Attachments

  • Peter john.jpg
    Peter john.jpg
    79.7 KB · Views: 159
This set of functions simplifies the management of lists or small database simulations in PIC18 environments. It provides tools for writing and reading data in specific fields of records, as well as for formatting the data list.

But the search, comparison, deletion and editing functions of the fields are not yet implemented.
 
This set of functions simplifies the management of lists or small database simulations in PIC18 environments. It provides tools for writing and reading data in specific fields of records, as well as for formatting the data list.

But the search, comparison, deletion and editing functions of the fields are not yet implemented.
Hi D,
I'm a bit slow, and will watch with interest, while learning, thanks.

Why did you use ASM for the POINTER section?
C
 
Last edited:
In order to use the same functions with different lists (arrays), instead of working with the name of the list (array), we work with the ram memory address where the first element of the array is located.

And the use of the asm code is to locate and assign the address of the first element of the array, because if I don't know where it is located I can't use it. This code is used because the language does not have a command that does this operation. Of course, with the IDE tool "Wach variables" you can see the address where the array that is used to store the data begins, to indicate it by hand in our program and not have to use that code. But the problem is that if you declare new variables in the program, the addresses of the variables can be changed, and you have to go back to "Wach variables" to see the new addresses and change them again in the program. That little code in asm is responsible for carrying out this operation automatically and updates the address every time it is compiled.

If you plan to work with only one database at a time, you can work with global variables in the functions, and then the list array is managed by its name and subindex, eliminating the need to work with memory addresses, and therefore, the code used asm it is is no longer necessary.
 
Last edited:
In order to use the same functions with different lists (arrays), instead of working with the name of the list (array), we work with the ram memory address where the first element of the array is located.

And the use of the asm code is to locate and assign the address of the first element of the array, because if I don't know where it is located I can't use it. This code is used because the language does not have a command that does this operation. Of course, with the IDE tool "Wach variables" you can see the address where the array that is used to store the data begins, to indicate it by hand in our program and not have to use that code. But the problem is that if you declare new variables in the program, the addresses of the variables can be changed, and you have to go back to "Wach variables" to see the new addresses and change them again in the program. That little code in asm is responsible for carrying out this operation automatically and updates the address every time it is compiled.

If you plan to work with only one database at a time, you can work with global variables in the functions, and then the list array is managed by its name and subindex, eliminating the need to work with memory addresses, and therefore, the code used asm it is is no longer necessary.
Hi D,
Thanks for the explanation, but the only way I will figure out how it works, is to play with it for a long time, as instructions don't suit my way of learning.

Regarding POINTER, this is now in Oshonsoft:
C
 

Attachments

  • POINTER.jpg
    POINTER.jpg
    106.5 KB · Views: 149
Pointer has been in the language for several years. The argument or value of pointer is a memory address, and this memory address belongs to a variable or a register of the microcontroller. The problem with pointer is that it has to be accompanied by a way to assign memory addresses at runtime, and it is something that the system currently does not have, so the true power of Pointer is wasted. I have asked an AI to expand the explanation of pointer in the manual, I attach the extension:

A pointer is a variable that stores the memory address of another variable. In the context of the programming language you are using, any integer variable can act as a pointer when used as an argument of the POINTER function. The POINTER function takes the value stored in the variable "x" as the memory address and returns the value stored at that memory location.

It is important to note that the value contained in the variable used as a pointer must be within the range of 0 to 4095, which is the range of RAM memory addresses available to the user in this system.

Here's an example to illustrate how a pointer is used:

Dim x As Word
Dim y As Byte

x = 0x3f ' Assigns a value to variable x
y = Pointer(x) ' Retrieves the value stored at the memory address pointed to by x
y = y + 0x55 ' Performs some operation with the retrieved value
x = x - 1 ' Modifies the value of x
Pointer(x) = y ' Stores the updated value at the memory address pointed to by x

y = 0xaa ' Assigns another value to variable y
x = x - 1 ' Modifies x again
Pointer(x) = y ' Stores the new value at the memory address pointed to by x

In this example, "x" is used as a pointer to access different memory locations, modify the values stored at those locations, and retrieve the values stored at those addresses for further processing.

A pointer is a special variable that stores the memory address of another variable. In a programming environment, every user-defined variable and each register of the microcontroller have a unique memory address, which is the physical location where they are stored in the system's memory. When we use a pointer, we are essentially working with memory addresses rather than variable values directly.

By using the POINTER function in your programming environment, you are allowing an integer variable to act as a pointer, meaning it can hold the memory address of any other variable or register in the system. This provides an efficient way to access and manipulate data stored in different memory locations.

In the provided example, the variable "x" is used as a pointer to access specific memory addresses. The POINTER function takes the value contained in "x" as the memory address it refers to. Then, we can manipulate the data stored at that memory location or store new data in it using the pointer "x".

This ability to work with memory addresses is fundamental to many operations in programming, such as manipulating complex data structures, dynamically allocating memory, and directly interacting with hardware devices through control registers. Pointers offer significant flexibility and power in data manipulation and resource management in computer and embedded systems.

Pointers offer several advantages when used with functions in programming:

1. **Indirect Access to Data**: By using pointers as function parameters, we can indirectly manipulate the data they point to. This is useful when we want to modify the content of a variable outside the scope of the function.

2. **Efficiency in Argument Passing**: When we pass pointers as function arguments instead of passing copies of the data, we avoid the overhead associated with creating and manipulating data copies. This can be especially useful with large or complex data structures.

3. **Dynamic Memory Management**: Pointers are essential for dynamic memory allocation and deallocation at runtime. This allows us to reserve and release memory as needed during program execution, which can be essential for handling variable or unknown-sized data.

4. **Flexibility in Data Structure Manipulation**: With pointers, we can efficiently build and manipulate complex data structures such as linked lists, trees, and graphs. This enables us to implement sophisticated algorithms and solve complex problems elegantly.

5. **Interaction with Hardware Devices**: In embedded systems, pointers are indispensable for directly interacting with hardware devices through control registers. This allows us to efficiently and flexibly control peripherals such as GPIO ports, ADCs, DACs, UARTs, among others.

In summary, using pointers with functions extends the capabilities of data manipulation and resource management in programming, providing greater efficiency, flexibility, and control over memory and hardware devices.
 
Pointer has been in the language for several years. The argument or value of pointer is a memory address, and this memory address belongs to a variable or a register of the microcontroller. The problem with pointer is that it has to be accompanied by a way to assign memory addresses at runtime, and it is something that the system currently does not have, so the true power of Pointer is wasted. I have asked an AI to expand the explanation of pointer in the manual, I attach the extension:

A pointer is a variable that stores the memory address of another variable. In the context of the programming language you are using, any integer variable can act as a pointer when used as an argument of the POINTER function. The POINTER function takes the value stored in the variable "x" as the memory address and returns the value stored at that memory location.

It is important to note that the value contained in the variable used as a pointer must be within the range of 0 to 4095, which is the range of RAM memory addresses available to the user in this system.

Here's an example to illustrate how a pointer is used:

Dim x As Word
Dim y As Byte

x = 0x3f ' Assigns a value to variable x
y = Pointer(x) ' Retrieves the value stored at the memory address pointed to by x
y = y + 0x55 ' Performs some operation with the retrieved value
x = x - 1 ' Modifies the value of x
Pointer(x) = y ' Stores the updated value at the memory address pointed to by x

y = 0xaa ' Assigns another value to variable y
x = x - 1 ' Modifies x again
Pointer(x) = y ' Stores the new value at the memory address pointed to by x

In this example, "x" is used as a pointer to access different memory locations, modify the values stored at those locations, and retrieve the values stored at those addresses for further processing.

A pointer is a special variable that stores the memory address of another variable. In a programming environment, every user-defined variable and each register of the microcontroller have a unique memory address, which is the physical location where they are stored in the system's memory. When we use a pointer, we are essentially working with memory addresses rather than variable values directly.

By using the POINTER function in your programming environment, you are allowing an integer variable to act as a pointer, meaning it can hold the memory address of any other variable or register in the system. This provides an efficient way to access and manipulate data stored in different memory locations.

In the provided example, the variable "x" is used as a pointer to access specific memory addresses. The POINTER function takes the value contained in "x" as the memory address it refers to. Then, we can manipulate the data stored at that memory location or store new data in it using the pointer "x".

This ability to work with memory addresses is fundamental to many operations in programming, such as manipulating complex data structures, dynamically allocating memory, and directly interacting with hardware devices through control registers. Pointers offer significant flexibility and power in data manipulation and resource management in computer and embedded systems.

Pointers offer several advantages when used with functions in programming:

1. **Indirect Access to Data**: By using pointers as function parameters, we can indirectly manipulate the data they point to. This is useful when we want to modify the content of a variable outside the scope of the function.

2. **Efficiency in Argument Passing**: When we pass pointers as function arguments instead of passing copies of the data, we avoid the overhead associated with creating and manipulating data copies. This can be especially useful with large or complex data structures.

3. **Dynamic Memory Management**: Pointers are essential for dynamic memory allocation and deallocation at runtime. This allows us to reserve and release memory as needed during program execution, which can be essential for handling variable or unknown-sized data.

4. **Flexibility in Data Structure Manipulation**: With pointers, we can efficiently build and manipulate complex data structures such as linked lists, trees, and graphs. This enables us to implement sophisticated algorithms and solve complex problems elegantly.

5. **Interaction with Hardware Devices**: In embedded systems, pointers are indispensable for directly interacting with hardware devices through control registers. This allows us to efficiently and flexibly control peripherals such as GPIO ports, ADCs, DACs, UARTs, among others.

In summary, using pointers with functions extends the capabilities of data manipulation and resource management in programming, providing greater efficiency, flexibility, and control over memory and hardware devices.
Hi D,
I get the genral idea, and if I could understand it would be useful.
My mate who helps me, suggested POINTERS perhaps I could show him your CODE and use the ASM if that's ok. He undestands it.
C
 
These are all the functions I created to manage the DataBase:

'*****************************************************************************************
'Functions for database handling and maintenance.
'*****************************************************************************************
'- MatchField: indicates the number of records where the Input String matches a specified field.
'- SearchField: searches from the specified record that matches the given string in the selected field.
'- DeleteField: is a function that removes a specific field from a record.
'- DeleteRecord: is a function that removes a specific Record.
'- EmptyRecord: indicates whether a given record is empty.
'- CopyRecord: copies one record over another.
'- UpdatedRecord: delete empty records and relocate records.
Primitives:
'- WriteField: Writes a copy of the input string to the requested field of the indicated recoerd.
'- ReadField: The requested field is returned according to the input parameters.
'- FormatDB: Function to format the list vector.
 
These are all the functions I created to manage the DataBase:

'*****************************************************************************************
'Functions for database handling and maintenance.
'*****************************************************************************************
'- MatchField: indicates the number of records where the Input String matches a specified field.
'- SearchField: searches from the specified record that matches the given string in the selected field.
'- DeleteField: is a function that removes a specific field from a record.
'- DeleteRecord: is a function that removes a specific Record.
'- EmptyRecord: indicates whether a given record is empty.
'- CopyRecord: copies one record over another.
'- UpdatedRecord: delete empty records and relocate records.
Primitives:
'- WriteField: Writes a copy of the input string to the requested field of the indicated recoerd.
'- ReadField: The requested field is returned according to the input parameters.
'- FormatDB: Function to format the list vector.
Hi D,
I looked in the CODE that you posted in #1 and serached for these FUNCTIONS but couldn't find them. Am I misunderstanding something?
C.
 
I add the library and an example to try.
I need to add line comments.
In my version of the IDE, sometimes the first time I compile I get an error with "Symbol", but this does not matter when compiling again.

Test_DB.jpg
 

Attachments

  • DataBaseLibrary.bas
    8.2 KB · Views: 154
  • DataBaseTest.bas
    3.2 KB · Views: 185
Last edited:
I add the library and an example to try.
I need to add line comments.
In my version of the IDE, sometimes the first time I compile I get an error with "Symbol", but this does not matter when compiling again.
Hi D, V5.13
I just gave this a try, and got an error? I tried compiling a few times!
I put both BAS folders in the same folder.
Am I doing soething wrong?
C
 
You will have to update the IDE for the example to work.
The example should work from v5.32:

News in version 5.32 (2024-02-08)
- Assembler: Implementation of the INCLUDE directive; used to insert code from external ASM files; can be nested with no limitations
- Basic Compiler: It is now possible to specify the length of each declared string variable by adding [length] suffix to the variable name
- Small app improvements
 
Last edited:
You will have to update the IDE for the example to work.
The example should work from v5.32:

News in version 5.32 (2024-02-08)
- Assembler: Implementation of the INCLUDE directive; used to insert code from external ASM files; can be nested with no limitations
- Basic Compiler: It is now possible to specify the length of each declared string variable by adding [length] suffix to the variable name
- Small app improvements
Hi D,
All working :)

I was listening to a podcast about soil, seeds, compost and regeneration. The podcaster was asking if anyone has a Data base for world wide result matching.
Can your D/B work for this application?
C
 

Attachments

  • D-B TEST.jpg
    D-B TEST.jpg
    180.6 KB · Views: 172
'*****************************************************************************************
'Functions for database handling and maintenance.
'*****************************************************************************************
'- MatchField: indicates the number of records where the Input String matches a specified field.
'- SearchField: searches from the specified record that matches the given string in the selected field.
'- DeleteField: is a function that removes a specific field from a record.
'- DeleteRecord: is a function that removes a specific Record.
'- EmptyRecord: indicates whether a given record is empty.
'- CopyRecord: copies one record over another.
'- UpdateRecord: delete empty records and relocate records.
'- DeleteMatchField: all but one record in which the input string match for the requested field was found is deleted.
'- WriteField: Writes a copy of the input string to the requested field of the indicated recoerd.
'- ReadField: The requested field is returned according to the input parameters.
'- FormatDB: Function to format the list vector.
'*****************************************************************************************

I was going to give the go-ahead to the database library and I realized that I am missing the main and most used functions:
- How many records are left free.
- Write in the first empty record you find.
 
These are the two functions that I add and that ends the library.

'- FreeRecord: indicates the number of free records.
'- FirstFreeRecord: indicates which is the first free record.
 
I have already finished the library to work with the database, and these are the functions:

'*****************************************************************************************
'Functions for database handling and maintenance.
'*****************************************************************************************
'- MatchField: indicates the number of records where the Input String matches a specified field.
'- SearchField: searches from the specified record that matches the given string in the selected field.
'- DeleteField: is a function that removes a specific field from a record.
'- DeleteRecord: is a function that removes a specific Record.
'- EmptyRecord: indicates whether a given record is empty.
'- FreeRecord: indicates the number of free records.
'- FirstFreeRecord: indicates which is the first free record.
'- CopyRecord: copies one record over another.
'- UpdateRecord: delete empty records and relocate records.
'- DeleteMatchField: all but one record in which the input string match for the requested field was found is deleted.
'- WriteField: Writes a copy of the input string to the requested field of the indicated recoerd.
'- ReadField: The requested field is returned according to the input parameters.
'- FormatDB: Function to format the list vector.
'*****************************************************************************************

I attach the final library and the test program.
The next thing is to program a library to create a menu that is flexible for different data inputs, and that is compatible with the previous library.

During the simulation it is hypnotic to see how the data from the records move through the vector.
Test DB.jpg
 

Attachments

  • Test DB.bas
    3.6 KB · Views: 163
  • DataBaseLibrary.bas
    11.6 KB · Views: 135

New Articles From Microcontroller Tips

Back
Top