Bark Dark

Jim Ault jimaultwins at yahoo.com
Fri Apr 1 13:25:36 EDT 2011


On Apr 1, 2011, at 9:38 AM, Bob Sneidar wrote:

> Hey pretty clever. You could even trap for newCard and deleteCard to  
> add and delete entries in the custom Property. That way you wouldn't  
> have to repeat through all the cards again except for maintenance.
Yes, to do a full implementation, you would
--  set the customproperties on stack preopen or close
--  set the customproperties when a new card that has the field placed  
on it is added
--    or when a card is deleted if it has the field placed on it

> It looks like the repeat loop is getting the value of a shared field  
> on each of the cards.
No, a shared field is one that offers a single value that is the same  
for all cards that it appears on.  It is like a clock on the wall that  
has the same value for all people in the room.  What you might mean is  
a regular field that appears on all cards but can store a different  
value on each card.

Of course, if a regular field is in a group that is not 'placed' on  
all cards, then the programmer would have to add the following:

if field "desiredCodeString" exists then
   --this card can be indexed, otherwise
   --    skip it  or  put empty into the data array[id]
end if

        -- OR --
try
   -- access field "desiredCodeString"
   --  if it is missing, the catch branch is executed
catch errNum

end try

This would also apply to any other stacks or substacks.
Substacks would have the main stack script in their message path
Other stacks would not.  In that case you could employ either
--  one or more stacksinuse
--     one or more back scripts


> Couldn't you just set the property array element to empty for each  
> card to initialize it, then have a custom function markme(theMark)  
> which would simply set the array element to whatever you passed in  
> theMark?
That is one way, but if the stack has 543 cards with values when it is  
opened, this would be the starting data set.
There are several ways of triggering and capturing the message.  One  
feature is to do some sort of spell check or restricted value list to  
keep the data clean.

Also, when a customproperty is changed or set, LC sends a system  
message SetProp that can be trapped.  In addition, getting a value  
triggers the GetProp message.  The programmer does not have to do  
anything except trap for these.  (see the dictionary)

on setProp
    if (condition) then do this
        -- update data and save stack
    else
        return  -- kill this message
    end if
end setProp

>
> Bob
>
>
> On Mar 31, 2011, at 5:23 PM, Jim Ault wrote:
>
>> On Mar 31, 2011, at 3:29 PM, Bob Sneidar wrote:
>>
>>> I don't think the property thing will work because I don't think  
>>> you can find a card with a property or enumerate them as such.  
>>> (This AIN'T Applescript man!"
>>>
>> The 'property thing' does not refer to the CARD properties,
>> but the customProperties of the STACK
>>
>> ---- tested in a working stack  ------------------
>> --note  fld statusCode  is NOT shared
>> --  flds desiredCodeString  notnowCodeString
>> --    ARE SHARED
>> -- fld output  is NOT shared
>> --  all fields are in a group that behaves as backgound
>>
>>
>> on doCustomPropertyRun
>>  --  I use 'cps' to mean 'cust prop set'
>>  set the customPropertySet of this stack to "cpsStatusCodes"
>>  --make this set empty
>>  set the customkeys of this stack to empty
>>
>>  --you only need to do the repeat when changes are made
>>  --  or when the stack closes
>>  repeat with k = 1 to the number of cards
>>     put word -1 of the short id of  card k into thisCdId
>>     get k & "^" & word 1 to -1 of fld "statusCode" of card k
>>     replace cr with space in IT
>>     set the cpsStatusCodes[ thisCdId ] of this stack to IT
>>  end repeat
>>  save this stack --if it is run in the IDE, but not if an app
>>
>>  --To get the list of 'marked cards' you would do the following  
>> type of operation
>>  set the customPropertySet of this stack to "cpsStatusCodes"
>>  put the customProperties of this stack into statusCodeList
>>  -- now make a regular list
>>  combine statusCodeList using cr and "^"
>>  set the itemdel to "^"
>>  if field "desiredCodeString"  is not empty then
>>     filter statusCodeList with "*" & field "desiredCodeString" & "*"
>>     --and now you have a list of cd id's
>>  end if
>>
>>  if field "notnowCodeString"  is not empty then
>>     filter statusCodeList without "*" & field "notnowCodeString" &  
>> "*"
>>     -- and you have a shorter list if any have been removed
>>  end if
>>  -- if you want the card order, use the following
>>  sort statusCodeList numeric by item 2 of each
>>  put statusCodeList into fld "output"
>>
>>  --this allows showing a list of hits and changing the final list  
>> in many ways
>> end doCustomPropertyRun
>>
>> ---------------------------------------

Jim Ault
Las Vegas






More information about the use-livecode mailing list