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

William de Smet wdesmet at wanadoo.nl
Sat Sep 16 08:49:45 EDT 2006


Wow, thanks a lot Eric!

Just one more thing: what if I want to put more than one line into the
text field?
Now it replaces the previous images everytime I press the button. It
needs to be put on a next line.

I used a code before like: after the last line...
But that doesn't seem to work.

William

2006/9/16, Eric Chatonet <eric.chatonet at sosmartsoftware.com>:
> 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
>
>


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



More information about the use-livecode mailing list