Re: Oddity in 'currentCard' function?

2023-11-13 Thread Bob Sneidar via use-livecode
I never create an object without immediately giving it a name. Problem solved. 
:-)

Bob S


On Oct 24, 2023, at 9:34 PM, Mark Waddingham via use-livecode 
 wrote:

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!).

___
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-26 Thread J. Landman Gay via use-livecode

On 10/26/23 2:26 PM, J. Landman Gay via use-livecode wrote:




It can be read if you supply syntax that requests a legal value; i.e.:

   the name of the currentCard of stack X
   the loc of the currentCard of stack X
   the backColor of the currentCard of stack X


Oops. That's wrong. It errors. This:

  put the loc of cd the currentcard of stack X
  etc...

--
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-26 Thread J. Landman Gay via use-livecode

On 10/26/23 11:17 AM, Mark Wieder via use-livecode wrote:

So basically to stay out of trouble "currentcard" should be thought of as a 
write-only property?


It can be read if you supply syntax that requests a legal value; i.e.:

  the name of the currentCard of stack X
  the loc of the currentCard of stack X
  the backColor of the currentCard of stack X

Cards themselves have no intrinsic value (what would they return?) but their properties do. 
Similarly, what would expect to see if you:


   answer stack X

--
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-26 Thread Mark Wieder via use-livecode

On 10/26/23 01:44, Mark Waddingham via use-livecode wrote:

Basically, its main use was for changing card (i.e. as a settable 
property); rather than finding out what card was current (since that was 
already catered for via interrogating 'this card of this stack').


So basically to stay out of trouble "currentcard" should be thought of 
as a write-only property?


--
 Mark Wieder
 ahsoftw...@gmail.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-26 Thread Paul Dupuis via use-livecode

On 10/26/2023 4:44 AM, Mark Waddingham via use-livecode wrote:
Basically, its [currentCard] main use was for changing card (i.e. as a 
settable property); rather than finding out what card was current 
(since that was already catered for via interrogating 'this card of 
this stack'). 


FYI - this is exactly what we use currentCard for in our application - 
change the card that will be displayed when a user shows/opens a stack 
to match a change in user data when the stack is not actually open yet.


___
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-26 Thread Mark Waddingham via use-livecode

On 2023-10-25 13:57, Paul Dupuis via use-livecode wrote:

On 10/25/2023 12:34 AM, Mark Waddingham via use-livecode wrote:


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.




Okay, I get that  id  is a legacy return value when 
there is no name.


I'd just like to confirm that:

this card of stack "X"
and
the currentCard of stack "X"

refer to the same card, even if in different ways (actual object 
reference vs short name)?


Yes - 'the currentCard of stack "X"' is equivalent to 'the short name of 
this card of stack X'.


The currentCard property was added a very long time ago to be used by a 
project which never saw the light of day (I'm not sure I remember what 
it was now!)...


There was (apparently!) a need at that time to be able to switch cards 
in a stack *without* the stack coming to front (which is what happens 
when you use the only alternative 'go card ... of stack').


It was added as a property as that was the quickest/fastest way to do 
so, for something which I don't remember being entirely convinced by at 
the time - it wasn't documented for a long time, but then I think 
someone asked about it and it had been there long enough and it doesn't 
do any harm really so it was documented.


Basically, its main use was for changing card (i.e. as a settable 
property); rather than finding out what card was current (since that was 
already catered for via interrogating 'this card of this stack').


With hindsight, if the ability to switch cards without bringing the 
stack to front is indeed useful then it should probably be provided via 
a new command, or an augmentation of the 'go' command (like we have go 
visible / go invisible).


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: Oddity in 'currentCard' function?

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

On 2023-10-25 15:41, Craig Newman via use-livecode wrote:

Paul.

The construction "answer this card of stack “X” does not work if you 
are not on stack “X”:


answer the  currentCard of stack  “X”  —works

answer the name of this card of stack “X —works

answer this card of stack “X”—Nope


'this card of this stack' is an object reference - when evaluated in 
contexts which don't expect an object reference, object references 
return the *content* of the object, or an error (if the object has no 
content)... Only buttons and fields have content - in which case 
evaluating them returns the 'text' of the object.


Most things *don't* expect an object reference - places that do are 
where an object needs to be acted on, rather than a value being needed.


For example:

  set the X of 
  put exists()
  put there is an 
  answer 

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: Oddity in 'currentCard' function?

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

The construction "answer this card of stack “X” does not work if you are not on 
stack “X”:

answer the  currentCard of stack  “X”  —works

answer the name of this card of stack “X —works

answer this card of stack “X”—Nope



Craig




> On Oct 25, 2023, at 8:57 AM, Paul Dupuis via use-livecode 
>  wrote:
> 
> On 10/25/2023 12:34 AM, Mark Waddingham via use-livecode wrote:
>> 
>> 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.
>> 
> 
> Okay, I get that  id  is a legacy return value when there is 
> no name.
> 
> I'd just like to confirm that:
> 
> this card of stack "X"
> and
> the currentCard of stack "X"
> 
> refer to the same card, even if in different ways (actual object reference vs 
> short name)?
> 
> If so, I will switch to using "this card of stack". I had thought that the 
> 'this card' was always the card in the object hierarchy of the object the 
> script was running in and had forgotten that you could say 'this card of 
> stack ...' to reference the active card in another stack.
> 
> 
> ___
> 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-25 Thread Paul Dupuis via use-livecode

On 10/25/2023 12:34 AM, Mark Waddingham via use-livecode wrote:


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.




Okay, I get that  id  is a legacy return value when 
there is no name.


I'd just like to confirm that:

this card of stack "X"
and
the currentCard of stack "X"

refer to the same card, even if in different ways (actual object 
reference vs short name)?


If so, I will switch to using "this card of stack". I had thought that 
the 'this card' was always the card in the object hierarchy of the 
object the script was running in and had forgotten that you could say 
'this card of stack ...' to reference the active card in another stack.



___
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 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: 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