Console container for put function?
Peter W A Wood
peterwawood at gmail.com
Sat Apr 25 05:21:48 EDT 2015
Mark
> On 25 Apr 2015, at 12:53, Mark Wieder <mwieder at ahsoftware.net> wrote:
>
> On 04/23/2015 11:09 PM, Peter W A Wood wrote:
>
>> I’m trying to find a better way than:
>>
>> if the environment is “server” then
>> put tResult
>> else
>> put tResult after Field tReport
>> end
>
> That's exactly how I deal with it, with the exception that I wrap it in a log function. That way there's only one place in the stack that needs to check the environment, and I can also put other conditions in the log file as needed
>
> command log pMessage
> if there_are_things_to_add_to_the_message ...
> end if
> if verboseMode ...
> if the environment is ...
> put ...
> else
> put ...
> end if
> end if
> end log
>
> log "I made it to function" && param(0)
> log "at this point the value of foo is" && foo
>
> --
> Mark Wieder
> ahsoftware at gmail.com <mailto:ahsoftware at gmail.com>
Thanks for that suggestion, I’ve does something like that.
I’ve now worked out a way of doing it without having to test the environment each time that I want to call put by using dispatch. There is an additional function call in place of checking the environment though.
local tReporter
command stackReporter pResult
put pResult & return after Field tReport
end stackReporter
command scriptReporter pResult
put pResult & return
end scriptReporter
command reportResult pResult
dispatch tReporter with pResult
end reportResult
if the environment is "server" then
put "scriptReporter" into tReporter
else
put "stackReporter" into tReporter
### code to set tReport # # #
end if
reportResult "My Result”
Regards
Peter
More information about the use-livecode
mailing list