imageSource again

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10090
Joined: Fri Feb 19, 2010 10:17 am

imageSource again

Post by richmond62 » Fri Apr 11, 2025 7:10 pm

I have a textField that contains the glyph "ѭ" somewhere in the text (but I have no way of knowing its position), and I should like to replace it with an image . . .

I tried:

Code: Select all

set the imageSource of char "ѭ" of fld "DICK" to 1015
(1015 is the number of the image

and I tried:

Code: Select all

set the imageSource of char "ѭ" of fld "DICK" to img "FUN"
to no avail . . .

Klaus
Posts: 14186
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: imageSource again

Post by Klaus » Fri Apr 11, 2025 7:13 pm

You need to supply the NUMBER of that character in the field for this!
Do like this:

Code: Select all

...
put offset( "ѭ", fld "DICK") into tCharNr
if it <> 0 then
set the imageSource of char tCharNr of fld "DICK" to 1015
...

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10090
Joined: Fri Feb 19, 2010 10:17 am

Re: imageSource again

Post by richmond62 » Fri Apr 11, 2025 7:27 pm

That's fantastic!

Thank you very much. 8)

Klaus
Posts: 14186
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: imageSource again

Post by Klaus » Fri Apr 11, 2025 7:41 pm

Sorry, little typo, must read:

Code: Select all

...
put offset( "ѭ", fld "DICK") into tCharNr
if tCharNr <> 0 then
set the imageSource of char tCharNr of fld "DICK" to 1015
...

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: imageSource again

Post by dunbarx » Fri Apr 11, 2025 9:59 pm

@Klaus.

What is the char you used as "empty"? It is ASCII 48.

@Richmond.

"char" is a keyword, and always is referred to by number.

Craig

Klaus
Posts: 14186
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: imageSource again

Post by Klaus » Fri Apr 11, 2025 10:04 pm

Hi Craig,
dunbarx wrote:
Fri Apr 11, 2025 9:59 pm
@Klaus.

What is the char you used as "empty"? It is ASCII 48.
...
Craig
Where did I use "empty"? :shock:

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: imageSource again

Post by dunbarx » Sat Apr 12, 2025 3:13 pm

Klaus.

My error, I meant "0" (zero).

In my reading of your handler, it appears that ASCII 48 (sort of a "theta") appears where zero ought to. Oddly, when I copied that char to a text editor, it comes over as zero. Here is what I saw:

[attachment=0]Theta.zip[/attachment
Craig
Attachments
Theta.zip
(10.48 KiB) Downloaded 49 times

Klaus
Posts: 14186
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: imageSource again

Post by Klaus » Sat Apr 12, 2025 4:38 pm

Oh, come on, Craig, look up "offset" in the dictionary! 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10090
Joined: Fri Feb 19, 2010 10:17 am

Re: imageSource again

Post by richmond62 » Sat Apr 12, 2025 5:07 pm

Well, personally I wouldn't get upset by what a ZERO looks like because I'd do this:

Code: Select all

put offset( "ѭ", fld "DICK") into tCharNr
if tCharNr is "ѭ" then
set the imageSource of char tCharNr of fld "DICK" to 1015
end if
No ZEROs are hurt this way. 8)

AND as the Bulgarians gave up using ѭ about 100 years ago nobody should take offence.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: imageSource again

Post by dunbarx » Sat Apr 12, 2025 5:16 pm

@Klaus.

What do you mean? If the offset function finds nothing, it returns zero. I was thrown by the odd char I saw on my screen, which resembles a zero but is not one, and simply asked you about it. Sheesh. :cry:

@ Richmond.

What is that glyph? Was it really a Bulgarian zero? Only an integer will do, you know.

Craig

Klaus
Posts: 14186
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: imageSource again

Post by Klaus » Sat Apr 12, 2025 5:26 pm

Sorry folks, don't understand your problem(s)? :shock:

"offset..." returns a NUMBER between 1 and (the number of chars in the field/text)
or ZERO = 0 if the character we are looking for is NOT in the field/text.
So in my example script tChar will NEVER be "ѭ"

I see 16 in the first ANSWER but never the second dialog.
offset.png
offset.png (33.63 KiB) Viewed 2222 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: imageSource again

Post by dunbarx » Sat Apr 12, 2025 5:42 pm

Klaus.

I know all that. And even zero is a NUMBER. 8)

The char in my attachment is not an "ordinary" zero. It is the way some people write a zero on a blackboard, in a math class here and there. But I have never seen a computer display it as such, and it threw me.

How did you make it that way?

Craig

Klaus
Posts: 14186
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: imageSource again

Post by Klaus » Sat Apr 12, 2025 5:48 pm

dunbarx wrote:
Sat Apr 12, 2025 5:16 pm
@Klaus.

What do you mean? If the offset function finds nothing, it returns zero. I was thrown by the odd char I saw on my screen, which resembles a zero but is not one, and simply asked you about it. Sheesh. :cry:
Sorry, looks like I did not understand what you meant, since I used definitively 0 for (if tCharNr = 0...)

Now I understand that it appeared as "ѭ" on your screen, no idea why. :shock:
But I typed as usual and only copy/pasted the "ѭ".

Klaus
Posts: 14186
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: imageSource again

Post by Klaus » Sat Apr 12, 2025 5:50 pm

richmond62 wrote:
Sat Apr 12, 2025 5:07 pm

Code: Select all

put offset( "ѭ", fld "DICK") into tCharNr
if tCharNr is "ѭ" then
set the imageSource of char tCharNr of fld "DICK" to 1015
end if
This will never work as you might exspect, see my last postings.
tCharNr will NEVER be ѭ!

How long have you been using Lc so far? 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10090
Joined: Fri Feb 19, 2010 10:17 am

Re: imageSource again

Post by richmond62 » Sat Apr 12, 2025 5:58 pm

That odd glyph is an outdated Bulgarian symbol (picked because the likelihood of it cropping up elsewhere is ZERO) for a sort of nasal vowel /jo/ (with a tilde over the 'o' for phonetic purists): luckily the Bulgarians (unlike the French) gave up speaking through their noses about 150 years syne.

Bulgarian went through 2 orthographical changes, 1 in 1928 (when they got rid of the nasals), and another in 1952 (commie stuff largely to make pre-commie texts more difficult to read: c.f. George Orwell's NewSpeak).

Anyhow, as that may be, I just chose something obscure as a placeholder for my images I wanted inwith my texts.

Post Reply