Re: Oddity in 'currentCard' function?

2023-10-24 Thread Mark Waddingham via use-livecode

On 2023-10-24 18:00, Paul Dupuis via use-livecode wrote:

I think I found a oddity in the "currentCard" property.

The documentation states that the currentCard property return the short 
name of the current card of a stack:


for example: put the currentCard of stack "Untitled 1" into tCardName

You can then execute code such as: set the myProperty of cd tCardName 
of stack "Untitled 1" to tValue


...

But again, breaking that example above (set the myProperty of the 
currentCard of stack "Untitled 1" to tValue) into 2 lines:

put the currentCard of stack "Untitled 1" into tCardName
set the myProperty of cd tCardName of stack "Untitled 1" to tValue
FAILS if the card has no name.

Something just seems off here?


As Jacque said, if an object has an empty name then the short name 
returns ` id ` (i.e. an id chunk) - this is long standing 
behavior and one which I'm not sure is entirely helpful (it should 
perhaps just return empty!).


You see the same effect in other properties which return a 'short name' 
- e.g. the menubar of a stack. So its entirely consistent with 'object 
name' properties. (In these cases there is no string which such 
properties could return which would help distinguish unnamed things and 
that could be used to resolve them in some sort of chunk in a consistent 
manner as object names can be arbitrary strings).


If you want to do stuff with the current card of a stack, then don't use 
the currentCard property - 'this card of stack ...' *is* a chunk 
reference and thus it doesn't care whether the card has a name or not.


If you want the long id of the current card of a stack to manipulate 
'out of context' then use the long id:


   put the long id of this card of stack ... into tCardId

Of course, if you really want to use the currentCard (for whatever 
reason), then you need to make sure all your cards have names (which to 
be fair, is a good habit to get into - as is naming all objects with 
some, unique, name!).


Warmest Regards,

Mark.

--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Build Amazing Things

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: drawingSvgCompileIcon(pIconName) always BLACK

2023-10-24 Thread Brian Milby via use-livecode
Well, it sure took me a while to get around to this.  I guess better late
than never though.  Not sure where the best place to put it, so I just
added it to my lc-misc repo on GitHub.  You can find the code here:
https://github.com/bwmilby/lc-misc/tree/master/IconDrawingLibrary

Thanks,
Brian

On Wed, Apr 6, 2022 at 3:20 PM Klaus major-k via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Hi Brian,
>
> > Am 06.04.2022 um 21:18 schrieb Brian Milby via use-livecode <
> use-livecode@lists.runrev.com>:
> >
> > I guess I need to make an update to this library :)
>
> yo, that would be cool! :-)
>
> > Sent from my iPhone
> >
> >> On Apr 6, 2022, at 1:28 PM, Mark Waddingham via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >>
> >> On 2022-04-06 18:16, Klaus major-k via use-livecode wrote:
> >>> Hi all,
> >>> so sorry, looks like I completely f. up here.
> >>> Sorry for the confusion, not may day...
> >>> See:
> >>> 
> >>
> >> Hehe - no worries.
> >>
> >> So in answer to your original query about wanting to be able to color
> the icons - the drawing library supports the 'currentColor' attribute in
> SVG - and this is tied to the 'backgroundColor' property of the image
> object the drawing is set on.
> >>
> >> It would only take a small tweak to Brian's extension to make this work
> - adding `fill="currentColor"` to the path node it generates.
> >>
> >> Brian's extension works by fetching the path data from the IconSVG
> library, wrapping it in the necessary SVG XML, and then compiling it with
> drawingSvgCompile.
> >>
> >> Irksomely, there does not seem to be any support for marking colors in
> SVGs as 'currentColor' in any SVG editor we've come across (unless its
> deeply buried in it). So one strategy there is making sure the colors you
> want to be configurable in the SVG are set to a known unlikely random color
> (e.g. #ABCDEF), exporting as SVG XML from the editor and then just doing a
> global find/replace of (e.g.) #ABCDEF with currentColor.
> >>
> >> Warmest Regards,
> >>
> >> Mark.
>
> Best
>
> Klaus
>
> --
> Klaus Major
> https://www.major-k.de
> https://www.major-k.de/bass
> kl...@major-k.de
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Oddity in 'currentCard' function?

2023-10-24 Thread J. Landman Gay via use-livecode
The behavior is consistent with all cards or controls that don't have a name. The "name" is the 
ID in that case. The best way around it is to:


  put the long id of  into tID

That way you can refer to tID without worrying whether there's a literal name 
or not. So:

  put the long ID of the currentCard into tID
  set the myProperty of tID to tValue


On 10/24/23 12:00 PM, Paul Dupuis via use-livecode wrote:

I think I found a oddity in the "currentCard" property.

The documentation states that the currentCard property return the short name of the current 
card of a stack:


for example: put the currentCard of stack "Untitled 1" into tCardName

You can then execute code such as: set the myProperty of cd tCardName of stack "Untitled 1" to 
tValue


However, if the card does not have a name set, then current card returns "card id ", 
example: card id 1002 and the above 2 lines of code return a runtime error of 'can't find card'


put the currentCard of stack "Untitled 1" into tCardName
set the myProperty of cd tCardName of stack "Untitled 1" to tValue

WORKS for cards with a name
FAILS for cards without a name (where currentCard returns 'card id Trying to execute: set the myProperty of cd tCardName of stack "Untitled 1" to tValue WHEN 
tCardName contain 'card id 1002' produces a run time error


But trying to execute: set the myProperty of cd id 1002 of stack "Untitled 1" 
to tValue works.

Oddly, set the myProperty of cd tCardName of stack "Untitled 1" to tValue FAILS if tCardName 
contains "id 10001" (and yes that card with that ID exists)


Oddly again, set the myProperty of the currentCard of stack "Untitled 1" to tValue DOES WORK 
whether they have a name or not


But again, breaking that example above (set the myProperty of the currentCard of stack 
"Untitled 1" to tValue) into 2 lines:

put the currentCard of stack "Untitled 1" into tCardName
set the myProperty of cd tCardName of stack "Untitled 1" to tValue
FAILS if the card has no name.

Something just seems off here?

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Oddity in 'currentCard' function?

2023-10-24 Thread Craig Newman via use-livecode
NitPicking within myself, but I have always isolated variables in “do” 
constructions:
do "set the myProperty of" && tCardName && "to" && tValue

Craig

> On Oct 24, 2023, at 1:59 PM, Craig Newman  wrote:
> 
> Paul.
> 
> Having a more complete description seems right to me. You are essentially 
> saying that if you use the moniker “the currentCard” that LC should know what 
> you are intending, the is, the current “card”, and not the current “something 
> else”.
> 
> It has to be one of those cases where, as Danny Goodman once said, “If a line 
> of code seem like it ought to work but does not, try using a “do” 
> construction to force another layer of resolution;
> 
> on mouseUp
> put the currentCard of stack "Untitled 1" into tCardName
> 
> do "set the myProperty of" && tCardName && "to tValue"
> 
> end mouseUp
> 
> This works, and shows that the referencing of these sorts of things in LC, 
> like in HC, is not quite as they read like.
> 
> Craig
> 
> 
>> On Oct 24, 2023, at 1:00 PM, Paul Dupuis via use-livecode 
>>  wrote:
>> 
>> I think I found a oddity in the "currentCard" property.
>> 
>> The documentation states that the currentCard property return the short name 
>> of the current card of a stack:
>> 
>> for example: put the currentCard of stack "Untitled 1" into tCardName
>> 
>> You can then execute code such as: set the myProperty of cd tCardName of 
>> stack "Untitled 1" to tValue
>> 
>> However, if the card does not have a name set, then current card returns 
>> "card id ", example: card id 1002 and the above 2 lines of code 
>> return a runtime error of 'can't find card'
>> 
>> put the currentCard of stack "Untitled 1" into tCardName
>> set the myProperty of cd tCardName of stack "Untitled 1" to tValue
>> 
>> WORKS for cards with a name
>> FAILS for cards without a name (where currentCard returns 'card id > 
>> I think currentCard should just return 'id 1002' rather than 'card id 1002' 
>> if a card has no name.
>> 
>> Trying to execute: set the myProperty of cd tCardName of stack "Untitled 1" 
>> to tValue WHEN tCardName contain 'card id 1002' produces a run time error
>> 
>> But trying to execute: set the myProperty of cd id 1002 of stack "Untitled 
>> 1" to tValue works.
>> 
>> Oddly, set the myProperty of cd tCardName of stack "Untitled 1" to tValue 
>> FAILS if tCardName contains "id 10001" (and yes that card with that ID 
>> exists)
>> 
>> Oddly again, set the myProperty of the currentCard of stack "Untitled 1" to 
>> tValue DOES WORK whether they have a name or not
>> 
>> But again, breaking that example above (set the myProperty of the 
>> currentCard of stack "Untitled 1" to tValue) into 2 lines:
>> put the currentCard of stack "Untitled 1" into tCardName
>> set the myProperty of cd tCardName of stack "Untitled 1" to tValue
>> FAILS if the card has no name.
>> 
>> Something just seems off here?
>> 
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Oddity in 'currentCard' function?

2023-10-24 Thread Craig Newman via use-livecode
Paul.

Having a more complete description seems right to me. You are essentially 
saying that if you use the moniker “the currentCard” that LC should know what 
you are intending, the is, the current “card”, and not the current “something 
else”.

It has to be one of those cases where, as Danny Goodman once said, “If a line 
of code seem like it ought to work but does not, try using a “do” construction 
to force another layer of resolution;

on mouseUp
put the currentCard of stack "Untitled 1" into tCardName

do "set the myProperty of" && tCardName && "to tValue"

end mouseUp

This works, and shows that the referencing of these sorts of things in LC, like 
in HC, is not quite as they read like.

Craig


> On Oct 24, 2023, at 1:00 PM, Paul Dupuis via use-livecode 
>  wrote:
> 
> I think I found a oddity in the "currentCard" property.
> 
> The documentation states that the currentCard property return the short name 
> of the current card of a stack:
> 
> for example: put the currentCard of stack "Untitled 1" into tCardName
> 
> You can then execute code such as: set the myProperty of cd tCardName of 
> stack "Untitled 1" to tValue
> 
> However, if the card does not have a name set, then current card returns 
> "card id ", example: card id 1002 and the above 2 lines of code 
> return a runtime error of 'can't find card'
> 
> put the currentCard of stack "Untitled 1" into tCardName
> set the myProperty of cd tCardName of stack "Untitled 1" to tValue
> 
> WORKS for cards with a name
> FAILS for cards without a name (where currentCard returns 'card id  
> I think currentCard should just return 'id 1002' rather than 'card id 1002' 
> if a card has no name.
> 
> Trying to execute: set the myProperty of cd tCardName of stack "Untitled 1" 
> to tValue WHEN tCardName contain 'card id 1002' produces a run time error
> 
> But trying to execute: set the myProperty of cd id 1002 of stack "Untitled 1" 
> to tValue works.
> 
> Oddly, set the myProperty of cd tCardName of stack "Untitled 1" to tValue 
> FAILS if tCardName contains "id 10001" (and yes that card with that ID exists)
> 
> Oddly again, set the myProperty of the currentCard of stack "Untitled 1" to 
> tValue DOES WORK whether they have a name or not
> 
> But again, breaking that example above (set the myProperty of the currentCard 
> of stack "Untitled 1" to tValue) into 2 lines:
> put the currentCard of stack "Untitled 1" into tCardName
> set the myProperty of cd tCardName of stack "Untitled 1" to tValue
> FAILS if the card has no name.
> 
> Something just seems off here?
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Oddity in 'currentCard' function?

2023-10-24 Thread Paul Dupuis via use-livecode

I think I found a oddity in the "currentCard" property.

The documentation states that the currentCard property return the short 
name of the current card of a stack:


for example: put the currentCard of stack "Untitled 1" into tCardName

You can then execute code such as: set the myProperty of cd tCardName of 
stack "Untitled 1" to tValue


However, if the card does not have a name set, then current card returns 
"card id ", example: card id 1002 and the above 2 lines of 
code return a runtime error of 'can't find card'


put the currentCard of stack "Untitled 1" into tCardName
set the myProperty of cd tCardName of stack "Untitled 1" to tValue

WORKS for cards with a name
FAILS for cards without a name (where currentCard returns 'card id I think currentCard should just return 'id 1002' rather than 'card id 
1002' if a card has no name.


Trying to execute: set the myProperty of cd tCardName of stack "Untitled 
1" to tValue WHEN tCardName contain 'card id 1002' produces a run time error


But trying to execute: set the myProperty of cd id 1002 of stack 
"Untitled 1" to tValue works.


Oddly, set the myProperty of cd tCardName of stack "Untitled 1" to 
tValue FAILS if tCardName contains "id 10001" (and yes that card with 
that ID exists)


Oddly again, set the myProperty of the currentCard of stack "Untitled 1" 
to tValue DOES WORK whether they have a name or not


But again, breaking that example above (set the myProperty of the 
currentCard of stack "Untitled 1" to tValue) into 2 lines:

put the currentCard of stack "Untitled 1" into tCardName
set the myProperty of cd tCardName of stack "Untitled 1" to tValue
FAILS if the card has no name.

Something just seems off here?

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode