Highest Image File ID

2012-03-21 Thread Bob Sneidar
Can anyone think of a quick way (other than a repeat loop) to determine the 
highest ID of all the image files in a stack? Since I have a datagrid, the 
assigned ID is way up there and I want to keep my image files in sequence. It 
would be great if there were a command to get ALL the objects of a stack or 
card as an array. Even if there were a way to get all the objects, I could use 
a filter command to get the ones I wanted. 

Bob



___
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: Highest Image File ID

2012-03-21 Thread J. Landman Gay

On 3/21/12 11:25 AM, Bob Sneidar wrote:

Can anyone think of a quick way (other than a repeat loop) to
determine the highest ID of all the image files in a stack?


The ID of the stack is the either the last-used ID or the next available 
one, I forget which. It doesn't discriminate between the kinds of 
controls though.


--
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: Highest Image File ID

2012-03-21 Thread Pete
Maybe get the ID of the last image of stack xyz?  Not sure if that would
work or not, I seem to remember having problems with using the last
keyword in the past but I think that was specifically to do with groups.
Pete

On Wed, Mar 21, 2012 at 9:49 AM, J. Landman Gay jac...@hyperactivesw.comwrote:

 On 3/21/12 11:25 AM, Bob Sneidar wrote:

 Can anyone think of a quick way (other than a repeat loop) to
 determine the highest ID of all the image files in a stack?


 The ID of the stack is the either the last-used ID or the next available
 one, I forget which. It doesn't discriminate between the kinds of controls
 though.

 --
 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-livecodehttp://lists.runrev.com/mailman/listinfo/use-livecode




-- 
Pete
Molly's Revenge http://www.mollysrevenge.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: Highest Image File ID

2012-03-21 Thread Bob Sneidar
Yup. And I want to reuse all those wasted ID's that the Datagrid left behind. I 
am writing a function using repeat loops and if I lock screen and messages it 
is quite fast. I Will post it when I am done for anyone who might find it 
useful. 

Bob


On Mar 21, 2012, at 9:49 AM, J. Landman Gay wrote:

 On 3/21/12 11:25 AM, Bob Sneidar wrote:
 Can anyone think of a quick way (other than a repeat loop) to
 determine the highest ID of all the image files in a stack?
 
 The ID of the stack is the either the last-used ID or the next available one, 
 I forget which. It doesn't discriminate between the kinds of controls though.
 
 -- 
 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


___
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: Highest Image File ID

2012-03-21 Thread Richmond

I just did this:

put the ID of the last control

and it worked a charm.

___
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: Highest Image File ID

2012-03-21 Thread J. Landman Gay

On 3/21/12 12:14 PM, Richmond wrote:

I just did this:

put the ID of the last control

and it worked a charm.


I think that will only give the highest ID on that card.

--
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: Highest Image File ID

2012-03-21 Thread Bob Sneidar
Thanks Richmond and Pete. What I want it for is to set the ID of the image I 
just created to theHighestID +1. Obviously, if I just created an image, those 
functions will return that image ID. 

As promised, I have written a function that I think is fairly bullet proof. It 
checks for an invalid object type, as well as handling singular or plural forms 
of object types. It returns a sorted list of whatever property for whatever 
object type you tell it, excluding duplicates. I will probably enhance it to 
accept a scope, either card or stack. I'm wondering if this would be more 
useful to others if each line was a list of the long ID of the object followed 
by the property value? 

eg. put objectList(buttons, short name, descending) into theButtonNames

function objectList theType, theProp, theSort
if the last char of theType is s then put char 1 to -2 of theType into 
theType
if theSort is empty then put ascending into theSort

if theSort is not in ascending.descending then
return Error: Invalid sort
end if

try
do get the   theProp   of   theType   1 of this card
catch theError
if item 1 of the last line of theError is 166 then
return Error: Invalid type
else
return Error:   the last line of theError
end if
end try

put empty into theObjectList
put 1 into theLineNum
put theType  s into thePluralType
put the name of this card into theStartCard
lock screen
lock messages

repeat with theCardNum = 1 to the number of cards of this stack
go card theCardNum

try
do put the number of   thePluralType   of this card into 
theTypeCount
repeat with theObjectNum = 1 to theTypeCount
do put the   theProp   of   theType  theObjectNum   
into theValue

if theValue is not in theObjectList then
put theValue into line theLineNum of theObjectList
add 1 to theLineNum
end if
end repeat
catch theError
breakpoint
end try
end repeat

go card theStartCard

if line 1 of theObjectList is a number then
do sort theObjectList numeric  theSort
else
do sort theObjectList  theSort
end if

return theObjectList
end objectList


On Mar 21, 2012, at 10:07 AM, Pete wrote:

 Maybe get the ID of the last image of stack xyz?  Not sure if that would
 work or not, I seem to remember having problems with using the last
 keyword in the past but I think that was specifically to do with groups.
 Pete
 
 On Wed, Mar 21, 2012 at 9:49 AM, J. Landman Gay 
 jac...@hyperactivesw.comwrote:
 
 On 3/21/12 11:25 AM, Bob Sneidar wrote:
 
 Can anyone think of a quick way (other than a repeat loop) to
 determine the highest ID of all the image files in a stack?
 
 
 The ID of the stack is the either the last-used ID or the next available
 one, I forget which. It doesn't discriminate between the kinds of controls
 though.
 
 --
 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-livecodehttp://lists.runrev.com/mailman/listinfo/use-livecode
 
 
 
 
 -- 
 Pete
 Molly's Revenge http://www.mollysrevenge.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


___
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: Highest Image File ID

2012-03-21 Thread Richmond

On 03/21/2012 07:45 PM, J. Landman Gay wrote:

On 3/21/12 12:14 PM, Richmond wrote:

I just did this:

put the ID of the last control

and it worked a charm.


I think that will only give the highest ID on that card.



Perhaps if one adds this:

put the ID of the last control in stack DAFTY

that would do the trick?

___
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: Highest Image File ID

2012-03-21 Thread Bob Sneidar
Okay I updated the function to return an array to account for properties that 
are in array form. It returns a numbered array with two keys, the long ID of 
the object, and the property of each object you passed as an argument. I had to 
remove the sorting though because I am not about to sort an array. So far as I 
know sorting does not work with arrays. There should be some kind of form of 
sort for arrays like: 

sort the keys of myArrayA by myArray[id] of each -- or maybe by element 2 of 
each

but of course there is not. At any rate sorting arrays is too much trouble, and 
I digress. 

Here's the updated function:

function objectList theType, theProp
if the last char of theType is s then put char 1 to -2 of theType into 
theType
if theSort is empty then put ascending into theSort

try
do get the   theProp   of   theType   1 of this card
catch theError
if item 1 of the last line of theError is 166 then
return Error: Invalid type
else
return Error:   the last line of theError
end if
end try

put empty into theObjectList
put empty into theObjectListA
put 1 into theLineNum
put theType  s into thePluralType
put the name of this card into theStartCard
lock screen
lock messages

repeat with theCardNum = 1 to the number of cards of this stack
go card theCardNum

try
do put the number of   thePluralType   of this card into 
theTypeCount
repeat with theObjectNum = 1 to theTypeCount
do put the long ID of   theType  theObjectNum   into 
theObjectID
do put the   theProp   of   theType  theObjectNum   
into theValue

if theValue is not in theObjectList then
put theObjectID into theObjectListA[theLineNum][LongID]
put theValue into theObjectListA[theLineNum][theProp]
put theValue into line 1 of theObjectList
add 1 to theLineNum
end if
end repeat
catch theError
breakpoint
end try
end repeat

go card theStartCard
return theObjectListA
end objectList

The results for a call like put objectList(images, short name) into 
theArrayA returns a result (in printKeys() format) like this:

1
 short name: imgLogonsHi
 LongID: image id 10101 of card id 1002 of stack 
/Users/bobsneidar/Documents/LiveCode Stacks/Conference Scheduler/CSL 
Main.livecode
2
 short name: barpattern.png
 LongID: image id  of card id 1002 of stack 
/Users/bobsneidar/Documents/LiveCode Stacks/Conference Scheduler/CSL 
Main.livecode

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