if and text: bug or feature?

This
iff cond then
text
...
endtext
endiff

works as expected.
But this
if cond text
...
endtext

works fine if the condition is true. If it is false, then things go haywire and as far as I can tell subsequent batch lines are swallowed (not executed) until a return (this was in a subroutine).
 

rconn

Administrator
Staff member
May 14, 2008
12,365
150
> This
> iff cond then
> text
> ...
> endtext
> endiff
> works as expected.
> But this
> if cond text
> ...
> endtext
> works fine if the condition is true. If it is false, then things go
> haywire and as far as I can tell subsequent batch lines are swallowed (not
> executed) until a return (this was in a subroutine).

WAD - and you *really* wouldn't want it to work any other way.

If an IF condition fails, IF will not execute the command, so the parser has
no way to know that you're trying to use a TEXT / ENDTEXT. The only way it
could know that would be to expand and execute the command in every
instance, which would render the IF moot! :-)

Bottom line - never, never, put a TEXT / ENDTEXT in an IF statement.

Rex Conn
JP Software
 
You may want to add a warning to the documentation of IF. I figured out what was going on but it took a while. Once I understood, I also had a good idea of what your response would be ;) too.

It just bugs me if there are exceptions to general rules (in my old age strike that... mature years I have trouble remembering them) and especially undocumented ones.
 
Similar threads
Thread starter Title Forum Replies Date
E Text copy bug Support 1
vefatica Tab (^t) in @FILEWRITE's text Support 2
R Bug TPIPE's pdf to text conversions don't work Support 2
Joe Caverly Using TYPE with non-English text Support 22
M Goto fails when a text endtext block precedes the code Support 5
Joe Caverly No blank line in TEXT...ENDTEXT in a LIBRARY function Support 8
S INPUT fails if the entered text contains pair of square brackets Support 6
Alpengreis List command: text truncated in find box (german) Support 9
vefatica Text invisible in v25 Support 10
S How to? What's the maximum size of the thread text ? Support 5
S FFIND text that includes " Support 7
S Setting Tabs=Bottom makes text turn black Support 6
Joe Caverly Multiple Text Searches at once using FFIND or TPIPE Support 4
AndrewJ TakeCommand v23 + ANSI color sequences leads to black on black text Support 6
D Grabbing html text with @line Support 3
M TCC screen text bright colors not as bright in 24 as 23 Support 5
vefatica Find Files/Text dialog: does it work? Support 0
Alpengreis Installer: text is still truncated in german language Support 2
Peter Murschall IDE destroys Text on Ctrl-U/Ctrl-Shift-U Support 12
WinLanEm Read Cyrillic text from a file Support 12
Charles Dye OSD loses ampersands in text Support 2
R How to? Display text same as in CMD Support 14
Glenn Bowes Strange text at startup Support 5
M Fixed Cannot use the "Browse..." function in "Find files/text" dialogbox Support 2
Peter Murschall WAD FOR reads Text in ASCII !??!? Support 7
B Documentation Reference/Windows X64: Redundant text at the end Support 0
Joe Caverly LIST /T (search for Text) Support 2
nikbackm How to? Find duplicate lines in text file Support 0
J Input text converts to uppercase Support 1
T How to? Select and Delete text Support 6
vhodro How to? Select text Support 10
D Highlighted Text Color? Support 2
vefatica Fixed No text in List View! Support 4
D Removing text with TPIPE Support 2
Frank locked file after "text > ..." Support 3
Joe Caverly Copying text of MSGBOX Support 0
Stefano Piccardi TPIPE and word to text conversion Support 4
A How to? filter text stream with a regular expression Support 11
Charles Dye Text selection in Take Command tab window Support 13
rconn Full text instant email notification Support 31
WadeHatler Any way to restore the Text Based "Select File" Windows in TCC Support 2
Jay Sage Function to Return Selected Text Support 2
mdwyer @replace - global use in a text file Support 3
E Line break in msgbox text Support 3
D Force For to treat set of values as text, not files Support 3
L command grouping with TEXT...ENDTEXT Support 1
R Misalignment of text Support 2
Jay Sage How Can SENDMAIL Create Messages with Plain Text and HTML Support 2
dcantor Help text for Date Formats Support 0
A Selecting text is very dificult with a background image Support 1

Similar threads