![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I use VFP 6 SP 5. I have also confirmed that the behaviour noted is the same under the VFP 9 beta. I was writing some table comparison code earlier this evening and ran into an interesting gotcha with comments or line continuation. I am not sure why it works the way it does, but I can reproduce the problem and the kludge to deal with it. Following is greatly-simplified code that illustrates the problem. In the actual program, I have a very long condition for the if necessitating breaking the line up with line continuation in order that the line be readable. Obviously, here the line continuation could be eliminated, but that is not the point. set talk off a1=1 a2=1 b1=2 b2=42 c1=3 c2=3 if a1#a2 or; b1#b2 or; c1#c2 ? "different" endif return Obviously, this code compares two sets of values and reports "different" if any of the pair values are not equal. In this case, they are not. On second thought, say that b1 and b2 do not need to be compared. I could just delete that part of the code, but I might want it back later, so I comment it out. The if is now: if a1#a2 or; ; &&***** b1#b2 or; c1#c2 However, this does not compile. Neither does: if a1#a2 or; &&***** b1#b2 or; c1#c2 This does compile: if a1#a2 or; ; &&***** b1#b2 or c1#c2 I use the ; && <comment> style of commenting heavily in my SQL create tables, as in: create table cwkc; (; ; wccseq c(4) not null,; && WCC Sequencer ; && (for crptwkc) wccode c(3) not null,; && Work Classification Code wccdesc c(35) not null,; && Work Classification Code Description altwccd c(3) not null; && Alternative WCC ) but I suppose I am just lucky that I have not previously done something like: create table cwkc; (; ; wccseq c(4) not null,; && This will cause trouble; ; && I just know it. wccode c(3) not null,; wccdesc c(35) not null,; altwccd c(3) not null; ) This does compile: create table cwkc; (; ; wccseq c(4) not null,; && This will cause trouble; it will, ; && I just know it. wccode c(3) not null,; wccdesc c(35) not null,; altwccd c(3) not null; ) What exactly is going on here? The trouble appears to be the semicolon after the && when the semicolon is at the end of the physical line. Why though when it is part of a comment? Sincerely, Gene Wirchenko Computerese Irregular Verb Conjugation: I have preferences. You have biases. He/She has prejudices. |
#3
| |||
| |||
|
|
I use VFP 6 SP 5. I have also confirmed that the behaviour noted is the same under the VFP 9 beta. I was writing some table comparison code earlier this evening and ran into an interesting gotcha with comments or line continuation. I am not sure why it works the way it does, but I can reproduce the problem and the kludge to deal with it. Following is greatly-simplified code that illustrates the problem. In the actual program, I have a very long condition for the if necessitating breaking the line up with line continuation in order that the line be readable. Obviously, here the line continuation could be eliminated, but that is not the point. set talk off a1=1 a2=1 b1=2 b2=42 c1=3 c2=3 if a1#a2 or; b1#b2 or; c1#c2 ? "different" endif return Obviously, this code compares two sets of values and reports "different" if any of the pair values are not equal. In this case, they are not. On second thought, say that b1 and b2 do not need to be compared. I could just delete that part of the code, but I might want it back later, so I comment it out. The if is now: if a1#a2 or; ; &&***** b1#b2 or; c1#c2 However, this does not compile. Neither does: if a1#a2 or; &&***** b1#b2 or; c1#c2 This does compile: if a1#a2 or; ; &&***** b1#b2 or c1#c2 |
|
if a1#a2 or; ; &&***** b1#b2 or; c1#c2 |
|
if a1#a2 or; &&***** b1#b2 or; c1#c2 |
#4
| |||
| |||
|
|
What I think is happening is: ; is a continuation ONLY if it is at the end of a line OR if it is followed only by a comment. |
|
if a1#a2 or; ; &&***** b1#b2 or; c1#c2 and if a1#a2 or; &&***** b1#b2 or; c1#c2 are really the same. The trailing ; continues the comment. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
#5
| |||
| |||
|
|
Jack Jackson <jacknospam (AT) pebbleridge (DOT) com> wrote: [snip] What I think is happening is: ; is a continuation ONLY if it is at the end of a line OR if it is followed only by a comment. The rules must be a bit more complicated than that or ; &&***** b1#b2 or; would work. [snip] if a1#a2 or; ; &&***** b1#b2 or; c1#c2 and if a1#a2 or; &&***** b1#b2 or; c1#c2 are really the same. The trailing ; continues the comment. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I think you have it. It makes sense as to explaining the behaviour, but it does not make sense for how it ought to be. Yet another gotcha to watch for. Should I make an acronym out of it? YAGTWF? Sincerely, Gene Wirchenko Computerese Irregular Verb Conjugation: I have preferences. You have biases. He/She has prejudices. |
#6
| |||
| |||
|
|
I don't quite understand the 'gotcha'. From the VFP 5 help file: Remarks Place a semicolon ( at the end of each comment line that continues to afollowing line. You cannot place && and a comment after the semicolon used to continue a command line to an additional line. |
![]() |
| Thread Tools | |
| Display Modes | |
| |