FieldCount (OpenInsight 32-bit Specific)
At 20 NOV 2003 04:32:18PM ps wing wrote:
Shouldnt this work???
DECLARE FUNCTION FIELDCOUNT
FOR F=FIELDCOUNT(V,@FM) TO 1 STEP -1
…
Works this way around:
FOR F=1 TO FIELDCOUNT(V,@FM)
….
At 20 NOV 2003 04:49PM Paul Rule wrote:
Good question.
I'd always wondered why that didn't work. I've always had to code around it.
At 20 NOV 2003 10:38PM ps wing wrote:
We are converting arev to oi code and guess we will have to use count(a,b)+(a#'') rather than fieldcount or dcount as both of these are fraud.
At 20 NOV 2003 11:14PM Pat McNerthney wrote:
ps wing,
The FIELDCOUNT assignment in a FOR statement problem has been fixed in the upcoming 7.0 release.
Pat
At 20 NOV 2003 11:33PM Donald Bakke wrote:
The FIELDCOUNT assignment in a FOR statement problem has been fixed in the upcoming 7.0 release.
I'm glad that this, as well as other, issues are being addressed. However, isn't it a bit unusual to put a function in the For statement itself? Doesn't this force the function to get called during each iteration? Plus, there is always the possibility that the value of the function might change depending on external conditions.
At 20 NOV 2003 11:53PM Richard Bright wrote:
Which is possibly why it hasnt been an issue :).
At 21 NOV 2003 12:23AM Pat McNerthney wrote:
Actually, in the initial assignment (which wasn't working) it is only done once, so performance wise it should be fine. If used for the test or for the increment value, then it does get executed every iteration which could effect performance. Also, depending on the function called and the parameters passed, you could get different results during each interation, which might or might not be a good thing.
Pat
At 24 NOV 2003 05:16AM Oystein Reigem wrote:
Paul,
You say it doesn't work. It doesn't even compile - right?
I don't think it has anything to do with the FieldCount function. It seems you can't have a function call as the firstindex of a For statement. Funny none of the responders said so. Perhaps it's common knowledge. But I wasn't aware of it.
- Oystein -
At 24 NOV 2003 04:55PM Paul Rule wrote:
Oystein,
You're right. Looks like you can't have any function as the first parameter in the FOR statement. Variables work ok though.
Its strange because you can have a function as the second parameter.
ie: for x=1 to fieldcount(var,@fm)
The first time I came across this I spent ages trying to find a non existent typo.
At 24 NOV 2003 09:57PM Pat McNerthney wrote:
Paul,
It is a bug in the Basic+ compiler. This will be fixed in 7.0.
Pat
At 26 NOV 2003 08:03AM Don Miller - C3 Inc. wrote:
Don B.
You're partly right. If the function is called as the Start Value of an iteration, then it won't get called during the loop. If it's called as either the End Value or Increment Value then it will. This could be highly problematical if the loop is doing an insertion of data into the string that is being evaluated. I have always made such variables static ahead of a loop that uses them.
Don M.
At 26 NOV 2003 08:12AM Oystein Reigem wrote:
Don M,
I quote from the Help in 4.1.2:
The value of index is tested against the value of lastindex at the beginning of each successive loop. If the test does not cause termination, the statements between the For and Next statements are executed. When End is exceeded, the loop terminates. Both Start and End (and Step) are evaluated each time through the loop, which can adversely affect performance.
It says here that the start value is evaluated many times - for each pass through the loop.
But it doesn't say it is used more than [i]once.
I don't know if this can be trusted, though.
- Oystein -
At 26 NOV 2003 08:47AM Don Miller - C3 Inc. wrote:
Oy ..
I wouldn't bet on it .. nor would I trust my daughter to go to the dance with it either. Have a happy .. you probably don't celebrate Thanksgiving the way we do .. but I wish you well anyway.
Don M.