Peter,
We have run into similar situation because of function overloading.
I tried William's example and as he says it don't call the HSerreceive function.
But if you change the hserreceive to hserreceive1 then it might work.
WAITFORCHAR62
;If hserreceive1 <> 62 then goto waitforChar62
rcall FN_HSERRECEIVE1
movlw 62
subwf HSERRECEIVE1,W,BANKED
btfss STATUS, Z,ACCESS
bra WAITFORCHAR62
Note now it does call FN_HSERRECEIVE1 and returns the value into the variable HSERRECEIVE1.
HSERRECEIVE1 is a valid function saying it is using com port number 1. it is in help file.
Calling hserreceive as a function don't really lessen your code because it calls the same subroutine and then puts it into a variable like your very first code.
BR
M
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@Mmotte is correct. This is caused by the compiler.
I thought I had written this up in the Help. But, I have failed you all.
Hugh will correct me....
These work;
'Call the function by adding the braces 'DoLoopWhileHSerReceive()<>62'Please the constant first - this is the general rule. Always put the constant first.'DoLoopWhile62<>HSerReceive
This fails as the function will not be called
DoLoopWhileHSerReceive<>62
Last edit: Anobium 2017-03-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@Peter
While using the function may make neater looking GCB source code, it also uses 5 more words of program memory and takes longer to execute than using the sub with no function.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a GSM modem which communicates via serial.
To send an SMS I need to wait for a ">" prompt to appear.
This works
But this doesn't:
Is there a way to get the second version to work, just to keep the code neater?
I'm using 0.97.01.
Post the section of errant ASM please. Let us look at what is happening.
I think this is the working ASM:
And I think this is the one that doesn't work:
In the second case is it treating
HSERRECEIVE
as a variable and not a function?Hserreceiveive subroutine and not a function so the second method will not work.
Correction. It is both a sub and a function so it should work I think
But the the ASM does not show an HserReceive sub. Only the HserReceive Variable
With limited testing it appears that a function cannot be used as part of a conditional statement
This DOES NOT Work
The function is never called since there is no function or sub for hserreceive in the ASM
ASM
Last edit: William Roth 2017-03-08
Peter,
We have run into similar situation because of function overloading.
I tried William's example and as he says it don't call the HSerreceive function.
But if you change the hserreceive to hserreceive1 then it might work.
Note now it does call FN_HSERRECEIVE1 and returns the value into the variable HSERRECEIVE1.
HSERRECEIVE1 is a valid function saying it is using com port number 1. it is in help file.
Calling hserreceive as a function don't really lessen your code because it calls the same subroutine and then puts it into a variable like your very first code.
BR
M
@Mmotte is correct. This is caused by the compiler.
I thought I had written this up in the Help. But, I have failed you all.
Hugh will correct me....
These work;
This fails as the function will not be called
Last edit: Anobium 2017-03-08
Both of those alternatives are neat enough for me.
Please review this Help.. you will have to scroll to the bottom of the page....
What changes are needed to improve this Help page?
And, this is a constraint of the current compiler. This constraint is a low priority in terms of being removed.
Last edit: Anobium 2017-03-08
@Peter
While using the function may make neater looking GCB source code, it also uses 5 more words of program memory and takes longer to execute than using the sub with no function.