Reputation: 4675
The NOSHOW
clause of the TEXT
command suppresses output to the main Fox window but the output still shows up in a log file set with SET ALTERNATE
. Can the text output be kept out of the text file somehow? Example:
set alternate to foo.log
set alternate on
* ...
local s
text to s noshow
this won't show up on the screen but it'll go into the file anyway
endtext
* ...
set alternate off
set alternate to
Issuing SET CONSOLE OFF
has no effect.
Background: I want to capture the text that gets output to the Fox screen but the code that produces the output contains some TEXT NOSHOW ... ENDTEXT
blocks for initialising multi-dimensional lookup arrays in worker objects. That text ends up in the file as well and makes it essentially useless, with a noise to signal ratio of about 1000 to 1. I don't want to go out and break the innocent worker code by surrounding the TEXT
blocks with SET ALTE
fiddling, hence this question.
Upvotes: 0
Views: 1041
Reputation: 23837
Instead of text ... endtext you could use Set Textmerge. ie:
Local s
Set Textmerge To Memvar s on Noshow
\\this won't show up on the screen nor will go into the file
Set Textmerge To
Set Textmerge Off
Upvotes: 1
Reputation: 4675
The objective was twofold. The primary objective was to capture output to a file for easy perusal - output that was the result of some leftover prototype/research code that could be useful in further prototyping/research. Example:
nVorhanden = bitor( ;
iif(empty(nvl(m.oPos.c_LK, 0)), 0, 1), ;
iif(empty(nvl(m.oPos.c_EDVNr, 0)), 0, 2) )
nFehlt = bitand(m.nPflicht, bitnot(m.nVorhanden))
if m.nFehlt <> 0
anzeige_Dateiname_und_LnwId_falls_noetig_(m.oLnw, @m.lDateinameAngezeigt)
? " Pos[" + transform(m.i) + "]: #" + transform(m.oPos.n_PlanPos), "'"
?? m.oPos.c_Text
?? "' ("
?? transform(m.oPos.c_LK)
?? "|"
?? transform(m.oPos.c_EDVNr)
?? "|Faktorsumme", transform(m.oPos.Faktorsumme())
?? "):"
if bittest(m.nFehlt, 0)
?? " LK-Nr. fehlt"
endif
if bittest(m.nFehlt, 1)
?? " EDV-Nr. fehlt"
endif
endif
Hacking kLOCs of stuff like that to use a different output method would been more work than it was worth. On the other hand, the interspersal with TEXT command output at a signal-to-noise ratio of 1 to 1000 made the captured output effectively useless.
The second objective was not to munge - and potentially break - the innocent library code that was using TEXT NOSHO ... ENDT
internally. So it was the user code that had to give way. In order to keep disruption/noise to a minimum a built a simple SET-ALTE-OFF class that can be used in strategic places to wrap TEXTy library calls like so:
* ...
with createobject([SET_ALTE_OFF_and_restore_later])
roIntp = CPaulaExcelinterpreter(m.oXLSX.c_Alias) && <- does TEXT ...
endwith
pruefe_Lnw(m.roIntp.o_Lnw) && <- does useful output
* ...
Actually it's all of the surrounding code that outputs interesting information, and only a small handful of TEXTy library calls.
Of all the alternatives considered, this adds the least amount of noise to the source code and it is safe in the face of exceptions flying about, without requiring an explicit FINALLY
frame and thus working even under Foxen that predate VFP8.
Naturally, the class is simple and straightforward:
define class SET_ALTE_OFF_and_restore_later as relation
c_ALTE = .null.
function Init
this.c_ALTE = set("ALTERNATE")
set alternate off
procedure Destroy
if this.c_ALTE == "ON"
set alternate on
endif
enddefine
Job done with a minimum of fuss.
The behaviour of TEXT NOSHOW ... ENDTEXT
vs. SET ALTERNATE
captures is still mighty odd, though...
Upvotes: 0