Throw me a frikkin bone

All flavors welcome.
Forum rules
Be kind.
Post Reply
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Throw me a frikkin bone

Post by richmond62 »

Why is this NOT replacing every 'ѧ' with an image?
-
Screenshot 2025-04-19 at 11.10.39.jpg
Screenshot 2025-04-19 at 11.10.39.jpg (138.39 KiB) Viewed 1168 times
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Throw me a frikkin bone

Post by richmond62 »

Obviously too much to expect someone to help.
-
Screenshot 2025-04-19 at 15.58.28.jpg
Screenshot 2025-04-19 at 15.58.28.jpg (135.33 KiB) Viewed 1163 times
https://richmondmathewson.owlstown.net/
User avatar
OpenXTalkPaul
Posts: 2836
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Throw me a frikkin bone

Post by OpenXTalkPaul »

richmond62 wrote: Sat Apr 19, 2025 1:00 pm Obviously too much to expect someone to help.
-
Screenshot 2025-04-19 at 15.58.28.jpg
That's more like a work around, 'replace' should replace every occurrence of your target unicode character in the field without that repeat loop.

Maybe try the newer form of 'replace', which is 'replace-in-feild' like so:
replace "Needle" with "Haystack" in field X preserving styles
Maybe that can handle the unicode better? It has a separate entry in the dictionary that says it was added in v7 (the other 'replace' entry say it was added in 1.0)
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Throw me a frikkin bone

Post by richmond62 »

Certainly worth a try . . . in due course . . . when I'm free . . .

Off to change the tyres on our car: seasonal requirement here in Bulgaria: what a ^&*()$#.
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Throw me a frikkin bone

Post by richmond62 »

Reading a bit more closely: that suggestion, Paul, is NOT going to solve the problem, as OXT Lite has NO problem at all showing Unicode characters inwith a text field.

The problem is 'beyond' that insofar that I bung unicode place marker characters in various locations in the text inwith a text field, and then replace them with images like this:

Code: Select all

if fld "DICK" contains "(constant)" then
      replace "(constant)" with (cr & numToCodePoint(1133) && "constant" & cr) in fld "DICK"
      set the caseSensitive to true
      repeat for each item MAGIC in "constant"
         put wordoffset(MAGIC , fld "DICK") into WITCH
         set the textColor of word WITCH of fld "DICK" to red
      end repeat
      put 1 into CYCLE
      repeat until CYCLE > GLYPHS
         if char CYCLE of fld "DICK" = numToCodePoint(1133) then
            set the imageSource of char CYCLE of fld "DICK" to 1365
         end if
         add 1 to CYCLE
      end repeat
   end if
What this DOES do is replace every instance of numToCodePoint(1133) with the image numbered 1365 and colour every instance of 'constant' red (as it should).

The PROBLEM is when this script runs:

Code: Select all

if fld "DICK" contains "(keyword)" then
      replace "(keyword)" with (cr & numToCodePoint(1134) && "keyword" & cr) in fld "DICK"
      set the caseSensitive to true
      repeat for each item MAGIC in "keyword"
         put wordoffset(MAGIC , fld "DICK") into WITCH
         set the textColor of word WITCH of fld "DICK" to red
      end repeat
      put 1 into CYCLE
      repeat until CYCLE > GLYPHS
         if char CYCLE of fld "DICK" = numToCodePoint(1134) then
            set the imageSource of char CYCLE of fld "DICK" to 1369
         end if
         add 1 to CYCLE
      end repeat
   end if
it replaces every instance of numToCodePoint(1134) with the image numbered 1369 and colour every instance of 'constant' red (as it should); BUT also removes all the instances of image number 1365 and set every instance of 'constant' back to black.
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Throw me a frikkin bone

Post by richmond62 »

To contextualise things further here is a stack that makes this explicitly clear:
-
Screenshot 2025-04-25 at 17.55.06.png
Screenshot 2025-04-25 at 17.55.06.png (121.83 KiB) Viewed 915 times
-

Code: Select all

on mouseup
   if fld "GUFF" contains "cheese" then
      replace "cheese" with (numToCodePoint(1127) && "cheese") in fld "GUFF"
      set the caseSensitive to true
      repeat for each item MAGIC in "cheese"
         put wordoffset(MAGIC , fld "GUFF") into WITCH
         set the textColor of word WITCH of fld "GUFF" to red
      end repeat
      put 1 into CYCLE
      repeat until CYCLE > 1000
         if char CYCLE of fld "GUFF" = numToCodePoint(1127) then
            set the imageSource of char CYCLE of fld "GUFF" to 1007
         end if
         add 1 to CYCLE
      end repeat
   end if
   ----
   if fld "GUFF" contains "fan" then
      replace "fan" with (numToCodePoint(1128) && "fan") in fld "GUFF"
      set the caseSensitive to true
      repeat for each item MAGIC in "fan"
         put wordoffset(MAGIC , fld "GUFF") into WITCH
         set the textColor of word WITCH of fld "GUFF" to purple
      end repeat
      put 1 into CYCLE
      repeat until CYCLE > 1000
         if char CYCLE of fld "GUFF" = numToCodePoint(1128) then
            set the imageSource of char CYCLE of fld "GUFF" to 1011
         end if
         add 1 to CYCLE
      end repeat
   end if
end mouseup
This code SHOULD:

1. Bung a 'Ch' image in front of each occurrence of the word 'cheese'.

2. Colour each occurrence of the word 'cheese' red.

3. Bung an 'F' image in front of each occurrence of the word 'fan'.

4. Colour each occurrence of the word 'fan' purple.

It does DO #1 (you can see this IF you put a wait in the code in the button ('Fromage Dure'); but the code for #3 and wipes the 'Ch' images out and reverts to the unicode place marker characters.

It ONLY manages to colour the first occurrence of 'cheese' red (#2), which is subsequently wiped out when the code ONLY manages to colour the first occurrence of 'fan' purple.

So, the whole shebang is not fit for purpose.
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Throw me a frikkin bone

Post by richmond62 »

And this is a load of cobblers:
-
Screenshot 2025-04-25 at 18.12.44.jpg
Screenshot 2025-04-25 at 18.12.44.jpg (139.47 KiB) Viewed 913 times
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Throw me a frikkin bone

Post by richmond62 »

Of course THIS works (re colourisation):

Code: Select all

on mouseup
   put the htmlText of fld "GUFF" into GUPH
   replace "cheese" with  "<font color=" & quote & "red" & quote & ">cheese</font>"  in GUPH
   replace "fan" with  "<font color=" & quote & "purple" & quote & ">fan</font>"  in GUPH
   set the htmlText of fld "GUFF" to GUPH
end mouseup
-
Screenshot 2025-04-25 at 18.32.53.png
Screenshot 2025-04-25 at 18.32.53.png (84.43 KiB) Viewed 908 times
-
Whether one can, subsequently, insert images has yet to be seen.
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Throw me a frikkin bone

Post by richmond62 »

Well, THIS worked:

Code: Select all

on mouseup
   if fld "GUFF" contains "cheese" then
      replace "cheese" with (numToCodePoint(1127) && "cheese") in fld "GUFF"
   end if
   if fld "GUFF" contains "fan" then
      replace "fan" with (numToCodePoint(1128) && "fan") in fld "GUFF"
      end if
      put the htmlText of fld "GUFF" into GUPH
      replace "cheese" with  "<font color=" & quote & "red" & quote & ">cheese</font>"  in GUPH
      replace "fan" with  "<font color=" & quote & "purple" & quote & ">fan</font>"  in GUPH
      set the htmlText of fld "GUFF" to GUPH
   end mouseup
-
Screenshot 2025-04-25 at 18.38.03.png
Screenshot 2025-04-25 at 18.38.03.png (87.67 KiB) Viewed 906 times
-
A really bad case of:
-
sBs.png
sBs.png (74.25 KiB) Viewed 906 times
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Throw me a frikkin bone

Post by richmond62 »

Cripes:

https://youtu.be/QbdCpi4qTNY

Code: Select all

on mouseup
   if fld "GUFF" contains "cheese" then
      replace "cheese" with (numToCodePoint(1127) && "cheese") in fld "GUFF"
   end if
   if fld "GUFF" contains "fan" then
      replace "fan" with (numToCodePoint(1128) && "fan") in fld "GUFF"
   end if
   ----
   put the htmlText of fld "GUFF" into GUPH
   replace "cheese" with  "<font color=" & quote & "red" & quote & ">cheese</font>"  in GUPH
   replace "fan" with  "<font color=" & quote & "purple" & quote & ">fan</font>"  in GUPH
   set the htmlText of fld "GUFF" to GUPH
   ----
   put the number of chars in fld "GUFF" into GNUM
   put 1 into CYCLE
   repeat until CYCLE > GNUM
      if char CYCLE of fld "GUFF" = numToCodePoint(1127) then
         set the imageSource of char CYCLE of fld "GUFF" to 1007
      end if
      if char CYCLE of fld "GUFF" = numToCodePoint(1128) then
         set the imageSource of char CYCLE of fld "GUFF" to 1011
      end if
      add 1 to CYCLE
   end repeat
end mouseup
-
Screenshot 2025-04-25 at 18.52.34.png
Screenshot 2025-04-25 at 18.52.34.png (92.2 KiB) Viewed 904 times
Attachments
Picture This.oxtstack
(4.85 KiB) Downloaded 35 times
https://richmondmathewson.owlstown.net/
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests