Hi Evan ,
The attached file ' MicroKP.gcb ' is a good, working file that compiled correctly with ver-1073 .
When I try to compile with the latest ver-1331 I get the following error message -
' MicroKP.gcb (49): Error: Missing Function Assignment - assign function result to a variable, or, change to a Subroutine'
I've racked my brains to find out what I did wrong, without any success.
Can you please help ?
Cheers
Geoffrey Younger
KPD is function. It is better to describe as KPD(). It therefore returns a value. I am guessing you are returning a byte value. So, assign the function to a byte value like myreturnedvaluefromKPDfunction = KPD
There was a functional change on 21/11/2023 1303 Fix COMPILER N/A Yes PIC Not required Updated to resolve Functions that are not assigned to a target variable[1560] as functions that do not assign the returned value was generating incorrect ASM.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Also, remove #define USELEGACYFORNEXT this is not a good idea. As this was meant as temp measure while we monitored the impact of the change to for-next loops. The compiler must be permitted to use the correct for-next structure.
The compiler will use the legacy mode for the for-next loop when it can. But #define USELEGACYFORNEXT forces legacy mode for every for-next loop... not recommend as libraries may need the 'working' for-next loop.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for all the useful information. I have done the following.
1. Dim myreturnedvaluefromKPDfunction as byte '
2. Function KPD() 'When called -> Returns PB value
3. Added myreturnedvaluefromKPDfunction = KPD just below the Function call
I tried to compile, but I still get the error msg. I then rem'd out #3 and tried to compile again but without success. Any further clues ?
Geoff
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The change was to ensure that the ASM generated was valid. The old compiler could, under certain circumstances, overwrite RAM values. So, the change ensure strict usage of functions.
If you have not donated to the funding for 2024 please consider. The funding is less than £10 GBP short of the target.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One final comment from me, Could you please update the Help File with this change to the
Function Statement. I spent an awful lot of time in there trying to figure out what had happened.
Cheers
Geoff
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was just about to delete your program here when I spotted something.
Using the code segement to explain.
Do'Main Program Loop for 4 way Keypad'CALL 1myreturnedvaluefromKPDfunction=KPD'call Function - KeyPad Decodelocate1,0'Line-2'----'CALL 2IfKPD=0Then'Print"None"'No Key PressedTestled=0' Data AvailableElse''CALL 3PrintKPD'Show Decoded ValuePrint"-"'Data SeparatorTestled=1' Data Available End If'----' Print adcPB 'showRAWvalue--UNcommentasrequiredwait250ms'For Demo only'-----locate1,0'Line2 - p rint spaces toPrint" "'Erase old KPD value ( 8 spaces )Loop'
If the code is as shown above you will get inconsistent results as you are/were reading the value of the ADC three times. I have shown these with the CALL 1,2,3 above.
You should read once in the variable myreturnedvaluefromKPDfunction and then use the variable for consistency.
Do'Main Program Loop for 4 way Keypad'CALL 1myreturnedvaluefromKPDfunction=KPD'call Function - KeyPad Decodelocate1,0'Line-2'----'CALL 2IfmyreturnedvaluefromKPDfunction=0Then'Print"None"'No Key PressedTestled=0' Data AvailableElse''CALL 3PrintmyreturnedvaluefromKPDfunction'Show Decoded ValuePrint"-"'Data SeparatorTestled=1' Data Available End If'----' Print adcPB 'showRAWvalue--UNcommentasrequiredwait250ms'For Demo only'-----locate1,0'Line2 - p rint spaces toPrint" "'Erase old KPD value ( 8 spaces )Loop'
Why does this give consistency? Reading three times means that at Call 1 you code get a one value, then at Call 2 the ADC changes.. you will get another value, and then at Call 3 the ADC changes.. you will get another value. Worse case scenario. So, the new segment Calls for the value once.
I have deleted the code here now. :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Evan ,
The attached file ' MicroKP.gcb ' is a good, working file that compiled correctly with ver-1073 .
When I try to compile with the latest ver-1331 I get the following error message -
' MicroKP.gcb (49): Error: Missing Function Assignment - assign function result to a variable, or, change to a Subroutine'
I've racked my brains to find out what I did wrong, without any success.
Can you please help ?
Cheers
Geoffrey Younger
KPD is function. It is better to describe as KPD(). It therefore returns a value. I am guessing you are returning a byte value. So, assign the function to a byte value like
myreturnedvaluefromKPDfunction = KPD
There was a functional change on
21/11/2023 1303 Fix COMPILER N/A Yes PIC Not required Updated to resolve Functions that are not assigned to a target variable[1560]
as functions that do not assign the returned value was generating incorrect ASM.Also, remove
#define USELEGACYFORNEXT
this is not a good idea. As this was meant as temp measure while we monitored the impact of the change to for-next loops. The compiler must be permitted to use the correct for-next structure.The compiler will use the legacy mode for the for-next loop when it can. But
#define USELEGACYFORNEXT
forces legacy mode for every for-next loop... not recommend as libraries may need the 'working' for-next loop.Thanks for all the useful information. I have done the following.
1. Dim myreturnedvaluefromKPDfunction as byte '
2. Function KPD() 'When called -> Returns PB value
3. Added myreturnedvaluefromKPDfunction = KPD just below the Function call
I tried to compile, but I still get the error msg. I then rem'd out #3 and tried to compile again but without success. Any further clues ?
Geoff
Like this...
Thank you Evan. I compiled and programmed the 15244. Works like a charm !
Cheers
Geoff
Pleasure.
The change was to ensure that the ASM generated was valid. The old compiler could, under certain circumstances, overwrite RAM values. So, the change ensure strict usage of functions.
If you have not donated to the funding for 2024 please consider. The funding is less than £10 GBP short of the target.
Donation Made
Thank you. 2024 funding target met!!!
One final comment from me, Could you please update the Help File with this change to the
Function Statement. I spent an awful lot of time in there trying to figure out what had happened.
Cheers
Geoff
A very good comment/point.
Updated see https://github.com/GreatCowBASIC/Help/blob/main/source/functions.adoc
You can change online if I have made editing errors.
I was just about to delete your program here when I spotted something.
Using the code segement to explain.
If the code is as shown above you will get inconsistent results as you are/were reading the value of the ADC three times. I have shown these with the
CALL 1,2,3
above.You should read once in the variable
myreturnedvaluefromKPDfunction
and then use the variable for consistency.Why does this give consistency? Reading three times means that at Call 1 you code get a one value, then at Call 2 the ADC changes.. you will get another value, and then at Call 3 the ADC changes.. you will get another value. Worse case scenario. So, the new segment Calls for the value once.
I have deleted the code here now. :-)
Many thanks for that.
Cheers
Geoff
Many thanks for that.
Cheers
Geoff