Is it possible to replace words with imagesource based upon user input?

William de Smet wdesmet at wanadoo.nl
Sat Sep 16 09:16:32 EDT 2006


Thanks Eric,

You're very kind.
I am learning every day!

greetings,

William

2006/9/16, Eric Chatonet <eric.chatonet at sosmartsoftware.com>:
> Hi again,
>
> First you could have more than an occurrence of a word in the same
> sentence.
> In addition you should handle plurals :-)
> Of course if you want to add the sentence to the field, you will add
> a html cr (<p></p>) after the current contents:
>
> on mouseUp
>    constant kWords = "School, Schools,Pupil, Pupils,Pencil,Pencils"
> -- etc.
>    constant kImages = "1001,1001,1002,1002,1003,1003" --
> corresponding IDs in the same order
>    local tSentence
>    ------
>    ask "Write a sentence:" with "New sentence"
>    if it = empty or it = "New sentence" then exit mouseUp
>    put it into tSentence
>    -----
>    repeat with i = 1 to the number of items of kWords
>      repeat until item i of kWords is not in tSentence
>        replace item i of kWords with "<img src=" \
>            & quote & item i of kImages & quote & ">" in tSentence
>      end repeat
>    end repeat
>    set the htmlText of fld "Text" to the htmlText of fld "Text" & "
> <p></p><p>" & tSentence & "</p>"
> end mouseUp
>
> I think you are done :-)
>
> Le 16 sept. 06 à 14:21, Eric Chatonet a écrit :
>
> > Hi William,
> >
> > I would not use the imageSource property but would handle the html.
> > Why?
> > Because imageSource applies only to a "real entity" in a field and
> > html allows to handle variables: much faster ;-)
> >
> > on mouseUp
> >   constant kWords = "School,Pupil,Pencil" -- etc.
> >   constant kImages = "1001,1002,1003" -- corresponding IDs in the
> > same order
> >   local tSentence,tFound
> >   ------
> >   ask "Write a sentence:" with "New sentence"
> >   if it = empty or it = "New sentence" then exit mouseUp
> >   put it into tSentence
> >   -----
> >   repeat with i = 1 to the number of items of kWords
> >     put wordOffset(item i of kWords, tSentence) into tFound
> >     if tFound <> 0 then
> >       replace item i of kWords with "<img src=" & item i of kImages
> > & ">" in tSentence
> >     end if
> >   end repeat
> >   set the htmlText of fld "Text" to "<p>" & tSentence & "</p>"
> > end mouseUp
> >
> > Note the compulsory parity between words and images IDs constants.
> > In addition, you might be interested in my "Encoded text picker"
> > plugin that will allow you to test many html combinations and
> > understand them easily.
> > See my website.
> >
> > Le 16 sept. 06 à 13:07, William de Smet a écrit :
> >
> >> Here's a nice one. I'd like to replace chars with imagesource based
> >> upon user input and so far I came up with this:
> >> on mouseUp
> >>  Ask "Write a sentence:"
> >>  put it into fld "text"
> >>  if the text of fld "text" contains "school"
> >>  then replace "school" with "Q" in fld "text"
> >>  then set the imagesource of the last char of fld "text" to 1009
> >>  end if
> >> end mouseUp
> >>
> >> As you can see there is a problem with this script:
> >> - always the last char is replaced with the imagesource even if there
> >> are three words in the sentence. It only works when you put just one
> >> word into it and that word is "school".
> >>
> >> I know I have to make a statement for every word the user puts into
> >> the sentence.
> >> I don't know you to combine it.
> >> Is it possible to replace a whole word with an imagesource?
> >>
> >> Who has a good idea?
> >>
> >> greetings,
> >>
> >> William de Smet
> >
> >
> > Best Regards from Paris,
> > Eric Chatonet
> > ----------------------------------------------------------------------
> > ------------------------
> > http://www.sosmartsoftware.com/    eric.chatonet at sosmartsoftware.com/
> >
> >
> > _______________________________________________
> > use-revolution mailing list
> > use-revolution at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-revolution
> >
>
>
> Best Regards from Paris,
> Eric Chatonet
> ------------------------------------------------------------------------
> ----------------------
> http://www.sosmartsoftware.com/    eric.chatonet at sosmartsoftware.com/
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>


-- 
ICT-coördinator
Herman Broerenschool
2612 SP Delft
015-2141066
http://www.hermanbroerenschool-delft.nl



More information about the Use-livecode mailing list