OutputText...

The Pixie
I have only just stumbled upon OutputText and OutputTextNoBr. I am curious at how they are set up. You have two pairs of functions doing essentially the same thing, and I am wondering why yiu do not amalgamate them, say like this?

  <function name="OutputText" parameters="text">
OutputTextOptBr (text, true)
</function>

<function name="OutputTextNoBr" parameters="text">
OutputTextOptBr (text, false)
</function>

<function name="OutputTextOptBr" parameters="text, linebreak">
data = NewDictionary()
dictionary add (data, "fulltext", text)
text = ProcessTextSection(text, data)
OutputTextRaw (text, linebreak)
</function>

<function name="OutputTextRaw" parameters="text, linebreak"><![CDATA[
s = "<span style=\"" + GetCurrentTextFormat("") + "\">" + text + "</span>"
if (linebreak) s = s + "<br/>"
JS.addText (s)
request (Speak, text)
]]></function>


Okay, still four functions, but two lines shorter and the complicated bits are only being done once, so better adherence to the DRY principle (so should be easier to maintain, etc.). This is in CoreOutput.aslx, by the way.

  <function name="OutputText" parameters="text">
<![CDATA[
data = NewDictionary()
dictionary add (data, "fulltext", text)
text = ProcessTextSection(text, data)
OutputTextRaw(text)
]]>
</function>

<function name="OutputTextRaw" parameters="text">
<![CDATA[
JS.addText("<span style=\"" + GetCurrentTextFormat("") + "\">" + text + "</span><br/>")
request (Speak, text)
]]>
</function>

<function name="OutputTextNoBr" parameters="text">
<![CDATA[
data = NewDictionary()
dictionary add (data, "fulltext", text)
text = ProcessTextSection(text, data)
OutputTextRawNoBr(text)
]]>
</function>

<function name="OutputTextRawNoBr" parameters="text">
<![CDATA[
JS.addText("<span style=\"" + GetCurrentTextFormat("") + "\">" + text + "</span>")
request (Speak, text)
]]>
</function>

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums