Hi,
I was a simple counting up loop in a flowcode version 2 program using as countmaximum a variable that was like everything else a byte, so it couldn't have a larger value than 255.
worked fine, also under version 3, but ....
The number of times I wanted to go through the counting routine before taking a next action was on the short side, I thought that changing the variable countmaximum to type integer and making it 512 for instance would do just that.
It compiles OK, but the pic16F88 used does not know what to do with it, it behaves as though the maximum count is reached the first time the program goes through the loop.
Any suggestions, did I interpret how to use integers wrong, need to change configuration settings of the pic, or ...?
fransky
use of integers in version 3 ?
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
The integers in Flowcode 3 should be 16 bit so a count of about 16000 should be possible. However if you are having probelms then why not have an inner loop count of 255 and then an outer loop count of 2 to reach your goal of 512,
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
integer as counter part 2
Thanks for the advice,
I am sure the two loop approach would solve my immediate issue (I thought about implementing such a solution, but with the availibility of integers in FC V3 that seemed unneccessary, the integer is such a more elegant solution, and we seem to agree it should work, so let's make it work).
My code is quite a program, I give the integer a value in one part of the program and use it in a macro that is called after that.
values up to 255 work fine, but when I make the value 256 it is immediately over.
I will run some experiments with a simplified version of the code, check whether it goes into the macro OK and keep track of how many times it goes through the countloop (none, once or ...?).
Any chance the problem has to do with local and global scopes of the declaration of the variable as integer? The documentation seemed to indicate something like that is not unthinkable?
If after my experiments the problem persists, I'll send you the simplified code and hopefully can also give you more test results a input.
best regards,
Fransky
I am sure the two loop approach would solve my immediate issue (I thought about implementing such a solution, but with the availibility of integers in FC V3 that seemed unneccessary, the integer is such a more elegant solution, and we seem to agree it should work, so let's make it work).
My code is quite a program, I give the integer a value in one part of the program and use it in a macro that is called after that.
values up to 255 work fine, but when I make the value 256 it is immediately over.
I will run some experiments with a simplified version of the code, check whether it goes into the macro OK and keep track of how many times it goes through the countloop (none, once or ...?).
Any chance the problem has to do with local and global scopes of the declaration of the variable as integer? The documentation seemed to indicate something like that is not unthinkable?
If after my experiments the problem persists, I'll send you the simplified code and hopefully can also give you more test results a input.
best regards,
Fransky
integer in countloop problem solved
Sometimes the solution is so easy (always in hindsight however).
I declared the value against which the counter was compared in the loop as integer. In one of the macro's were a countloop was used, I did not declare the actual counter as an integer but as a byte, as in the existing flowcode 2 version of the macro.
Thought I'd post this, maybe help someone not wander about this for a few hours.
fransky
I declared the value against which the counter was compared in the loop as integer. In one of the macro's were a countloop was used, I did not declare the actual counter as an integer but as a byte, as in the existing flowcode 2 version of the macro.
Thought I'd post this, maybe help someone not wander about this for a few hours.
fransky