answer "<anything>1234</anything>" is just 1234 ?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Fermin
Posts: 142
Joined: Fri Jun 05, 2015 10:44 pm

answer "<anything>1234</anything>" is just 1234 ?

Post by Fermin » Mon Apr 09, 2018 7:36 pm

WHY?...

put "<anything>1234</anything>"
-- result:
-- <anything>1234</anything>
-------
answer "<anything>1234</anything>"
-- result:
-- 1234

Fermin
Posts: 142
Joined: Fri Jun 05, 2015 10:44 pm

Re: answer "<anything>1234</anything>" is just 1234 ?

Post by Fermin » Mon Apr 09, 2018 7:56 pm

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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: answer "<anything>1234</anything>" is just 1234 ?

Post by richmond62 » Mon Apr 09, 2018 8:46 pm

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.
stripper.png

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
Stripper.livecode.zip
Here's the stack.
(49.07 KiB) Downloaded 174 times
Last edited by richmond62 on Mon Apr 09, 2018 10:18 pm, edited 1 time in total.

livecodeali
Livecode Staff Member
Livecode Staff Member
Posts: 192
Joined: Thu Apr 18, 2013 2:48 pm

Re: answer "<anything>1234</anything>" is just 1234 ?

Post by livecodeali » Mon Apr 09, 2018 9:24 pm

The field displayed in the answer dialog uses html text (so you can do

Code: Select all

answer "<b>This is bold!</b>"
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 "&lt;" in pValue
    replace ">" with "&gt;" in pValue
    return pValue
end escape
and then do

Code: Select all

log "<anything>1234</anything>"
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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: answer "<anything>1234</anything>" is just 1234 ?

Post by dunbarx » Mon Apr 09, 2018 9:33 pm

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

Fermin
Posts: 142
Joined: Fri Jun 05, 2015 10:44 pm

Re: answer "<anything>1234</anything>" is just 1234 ?

Post by Fermin » Mon Apr 09, 2018 9:40 pm

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.

Fermin
Posts: 142
Joined: Fri Jun 05, 2015 10:44 pm

Re: answer "<anything>1234</anything>" is just 1234 ?

Post by Fermin » Mon Apr 09, 2018 9:45 pm

Oops, I just saw the answers from dunbarx and livecodeali.
Thank you very much.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”