Trying to compile and run an old program that needs to be modified, with the latest version of GCBasic (0.9 28/06/2007), results in trouble with array index; the first element of array is static, in other words not modificable.
For example:
' first of all array declaration
Dim Array(5)
' then a value to array elements
Array$ = "Hello"
Array(1) = 32 'first element of array to SPACE character
locate 1,2
print Array$ 'Hello comes on LCD Display without any modification
Array(2) = 32
locate 1,2
print Array$ 'H llo print out on LCD Display. That's OK
Using GCBasic version from 10/02/2007 this program works as expected.
Another problem is that it is not possible to initialize an array to NULL.
For instance, the following piece of code:
' first of all array declaration
Dim Array(5)
Array$ = "" ' Initialize Array
.
.
Array$ = "12345" ' New values for Array elements
locate 1,2
print Array$
Has unpredicable result, whereby it works perfectly with GCBasic version from 10/02/2007
Best regards
Stefano Bonomi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm not sure what caused the first error, but I made some alterations to the handling of arrays in July and this seems to have removed the bug.
The second error was caused by an issue with the SysReadString routine when copying null strings from program memory. It was passing a bad address to some computed goto code. I've fixed this and changed http://gcbasic.sourceforge.net/newfiles/update.zip .
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, I made a mistake and replaced STATUS.Z with STATUS.C, without realising that incf does not alter C. This caused more problems with the computed goto code used to read strings.
Thanks for reporting the bugs, and having the patience to wait while I track them down and attempt to fix them!
I'm not sure what is causing the trouble with the null string. This program compiles fine for me, and runs as expected:
#include "mytest.h"
Dim TestArray(5)
TestArray$ = ""
Temp = 0
Do
Temp += 1
Cls
LCDInt Temp
Wait 250 ms
Loop
I've also tried putting in a print after setting the array to a null string, and that works properly too.
While I'm certain that I included the fixed system.h in update.zip, it's possible that something went wrong. Perhaps you could try http://gcbasic.sourceforge.net/newfiles/system.h ? I've made a few more alterations to it since to (hopefully) handle null strings when added to other strings.
If that still doesn't work, could you please email me a copy of the program or post it here?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Trying the new system.h you provided me, did the trick.
I think it is better you replace the old one in update.zip too.
Compiling this simple test with the old system.h produces flashing "Hello World" text on LCD Display, compiling the same with the new version of the library, works as expected.
("Hello World" on LCD Display, then after 5 sec delay, only "World" on the second LCD line, and then loop).
Thanks a lot for your support
Stefano Bonomi
#chip 16F690,8
#config _INTRC_OSC_NOCLKOUT, _WDT_OFF,_PWRTE_OFF,_MCLRE_OFF,_CP_OFF, _BOR_OFF, _IESO_OFF,_FCMEN_OFF
#Define LCD_IO 2
#Define LCD_DB Porta.0 'Required: pin where Data Bit is wired
#Define LCD_CB Porta.1 'Required: pin where Clock Bit is wired
ADOFF
Dim Array1(5)
Dim Array2(5)
do
Array1$ = "Hello"
Array2$ = "World"
CLS
Locate 0,0
Print Array1$
locate 1,0
print Array2$
wait 5 s
CLS
Array1$ = ""
locate 1,0
print Array2$
wait 5 s
loop
end
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Trying to compile and run an old program that needs to be modified, with the latest version of GCBasic (0.9 28/06/2007), results in trouble with array index; the first element of array is static, in other words not modificable.
For example:
' first of all array declaration
Dim Array(5)
' then a value to array elements
Array$ = "Hello"
Array(1) = 32 'first element of array to SPACE character
locate 1,2
print Array$ 'Hello comes on LCD Display without any modification
Array(2) = 32
locate 1,2
print Array$ 'H llo print out on LCD Display. That's OK
Using GCBasic version from 10/02/2007 this program works as expected.
Another problem is that it is not possible to initialize an array to NULL.
For instance, the following piece of code:
' first of all array declaration
Dim Array(5)
Array$ = "" ' Initialize Array
.
.
Array$ = "12345" ' New values for Array elements
locate 1,2
print Array$
Has unpredicable result, whereby it works perfectly with GCBasic version from 10/02/2007
Best regards
Stefano Bonomi
I'm not sure what caused the first error, but I made some alterations to the handling of arrays in July and this seems to have removed the bug.
The second error was caused by an issue with the SysReadString routine when copying null strings from program memory. It was passing a bad address to some computed goto code. I've fixed this and changed http://gcbasic.sourceforge.net/newfiles/update.zip .
Unfortunately with this last update LCD doesn't work anymore (in 2 bit mode for sure, don't know in 4 and 8 bit mode).
Trying the same simple LCD test program with compiler version from 10/02/2007, it works without any problem......
Greetings
Stefano Bonomi
I forgot to mention that with the penultimate version of UPDATE.ZIP LCD was still working in 2 bit mode.
I mean the bug appeared in the latest version you posted in your answer to this Thread......
Best regards
Stefano Bonomi
Sorry, I made a mistake and replaced STATUS.Z with STATUS.C, without realising that incf does not alter C. This caused more problems with the computed goto code used to read strings.
I've now fixed update.zip. Also, I've put just the fixed gcbasic.exe in another file, http://gcbasic.sourceforge.net/newfiles/gcbasic-exe.zip - this is a little smaller to download (182 K instead of 593 K).
One strange thing I noticed was that the LCD would work in 4-bit mode if I reset the PIC while it was initialising the LCD.
First of all many thanks for your time and effort.
LCD is fixed now, but the problem with initializing Array to null remain
i.e.
Dim Example(5)
Example$=""
Produces odd results. (Program go crazy)
Many greetings
Stefano Bonomi
Thanks for reporting the bugs, and having the patience to wait while I track them down and attempt to fix them!
I'm not sure what is causing the trouble with the null string. This program compiles fine for me, and runs as expected:
#include "mytest.h"
Dim TestArray(5)
TestArray$ = ""
Temp = 0
Do
Temp += 1
Cls
LCDInt Temp
Wait 250 ms
Loop
I've also tried putting in a print after setting the array to a null string, and that works properly too.
While I'm certain that I included the fixed system.h in update.zip, it's possible that something went wrong. Perhaps you could try http://gcbasic.sourceforge.net/newfiles/system.h ? I've made a few more alterations to it since to (hopefully) handle null strings when added to other strings.
If that still doesn't work, could you please email me a copy of the program or post it here?
All ok now.
Trying the new system.h you provided me, did the trick.
I think it is better you replace the old one in update.zip too.
Compiling this simple test with the old system.h produces flashing "Hello World" text on LCD Display, compiling the same with the new version of the library, works as expected.
("Hello World" on LCD Display, then after 5 sec delay, only "World" on the second LCD line, and then loop).
Thanks a lot for your support
Stefano Bonomi
#chip 16F690,8
#config _INTRC_OSC_NOCLKOUT, _WDT_OFF,_PWRTE_OFF,_MCLRE_OFF,_CP_OFF, _BOR_OFF, _IESO_OFF,_FCMEN_OFF
#Define LCD_IO 2
#Define LCD_DB Porta.0 'Required: pin where Data Bit is wired
#Define LCD_CB Porta.1 'Required: pin where Clock Bit is wired
ADOFF
Dim Array1(5)
Dim Array2(5)
do
Array1$ = "Hello"
Array2$ = "World"
CLS
Locate 0,0
Print Array1$
locate 1,0
print Array2$
wait 5 s
CLS
Array1$ = ""
locate 1,0
print Array2$
wait 5 s
loop
end