Page 1 of 1
answer "<anything>1234</anything>" is just 1234 ?
Posted: Mon Apr 09, 2018 7:36 pm
by Fermin
WHY?...
put "<anything>1234</anything>"
-- result:
-- <anything>1234</anything>
-------
answer "<anything>1234</anything>"
-- result:
-- 1234
Re: answer "<anything>1234</anything>" is just 1234 ?
Posted: Mon Apr 09, 2018 7:56 pm
by Fermin
I'm programming a utility to generate KML code and I need to check items with"<" and">" signs and I could use to use the "answer" command but I don't seem to get the answer I need.
Anyway, I'll find another system.
Thank you very much.
Re: answer "<anything>1234</anything>" is just 1234 ?
Posted: Mon Apr 09, 2018 8:46 pm
by richmond62
I'll find another system.
I wonder if you are not jumping too quickly.
I had never heard of 'KML code' until I saw your post: but a quick look here:
https://developers.google.com/kml/documentation/kml_tut
was instructive.
NOW: for starters: if you use a
PUT statement, anything
you put inside
double quotes will be
PUT.
So, that is not going to work.
KML looks a lot like HTML, so there is no question of 'anything' being put between < and > signs,
just a few possible words and forward slashes.
What is also NOT clear from your postings is whether you are trying to GENERATE KML code
or something else because your example makes me think you are trying to strip KML code of
its markup symbols and end up with JUST the content in an unstyled context.
Code: Select all
on mouseUp
put fld "KML" into fld "CLEAN"
put 1 into KOUNT
repeat until line KOUNT of fld "fREMOVES" is empty
put line KOUNT of fld "fREMOVES" into XXXX
replace XXXX with " " in field "CLEAN"
add 1 to KOUNT
end repeat
end mouseUp
Re: answer "<anything>1234</anything>" is just 1234 ?
Posted: Mon Apr 09, 2018 9:24 pm
by livecodeali
The field displayed in the answer dialog uses html text (so you can do
And get bold text in the answer dialog. Your tags are being interpreted as html. If you want to use the answer dialog, perhaps use the following instead:
Code: Select all
command log pValue
answer escape(pValue)
end log
function escape pValue
replace "<" with "<" in pValue
replace ">" with ">" in pValue
return pValue
end escape
and then do
instead of
Code: Select all
answer "<anything>1234</anything>"
.
That way you can also keep your logging statements in and change the implementation when you no longer need an answer dialog to pop up.
Re: answer "<anything>1234</anything>" is just 1234 ?
Posted: Mon Apr 09, 2018 9:33 pm
by dunbarx
Do you see what Richmond is saying?
"Put" is as he stated. Just verbatim strings.
"Answer" evaluates the argument first, and then puts the "result" of that processing into a dialog. It works similarly to parameter passing and certain other LC commands and functions. Anyway, just so you do not see this as a mystery, the "KML" business notwithstanding
Craig Newman
Re: answer "<anything>1234</anything>" is just 1234 ?
Posted: Mon Apr 09, 2018 9:40 pm
by Fermin
Thank you, richmond62
I use KML to create virtual flights with Google Earth and I need to create and control elements similar to these:
<longitude>-2.928917744688542</longitude>
<latitude>43.26654581195621</latitude>
<altitude>14</altitude>
<heading>44</heading>
<tilt>82</tilt>
<range>10</range>
<altitudeMode>absolute</altitudeMode>
- - - -
This is a small fragment of my LiveCode application:
put "duration" into elTag
put cogeValTag1Eve (elTag, rp2, eve) into valor /*goes to a funtction*/
put "<" & elTag & ">" & valor & "</" & elTag & ">" into tg
/* This is the part that doesn't work, but it's not fatal either. I'll use another method.: */
answer tg with "parar" or "seguir"; if it is "parar" then exit to top
- - - -
The funny thing is that the command 'answer' doesn't seem to respond as expected if it includes characters like '</'.
I repeat my thanks.
Re: answer "<anything>1234</anything>" is just 1234 ?
Posted: Mon Apr 09, 2018 9:45 pm
by Fermin
Oops, I just saw the answers from dunbarx and livecodeali.
Thank you very much.