[APBeta] Script help

I.R. van de Stadt irvandestadt at hotmail.com
Fri Jul 8 17:56:02 PDT 2011


I sincerely hope that Paul will help you out.
A really useful script-idea and I'm looking forward to that one.
Inge

From: jey at adobe.com
To: APBeta at lists.astroplanner.net
Date: Sat, 9 Jul 2011 01:12:02 +0100
Subject: [APBeta] Script help



Paul, I’ve written the following script to allow editing of user image descriptions (and some of the flags).  The first dialog shows a list of user images.  Double-clicking one of them brings up an edit dialog which allows you to edit the description and two of the flags. The first dialog list is doing a string-sort instead of an ID-sort, though.  Is there a way to return ID for the MultiFieldObject’s ColumnType so the list will sort correctly? Thanks,Jeff. function EditImage(img as Image) as boolean     dim editor as Dialog, imgCanvas as Canvas     editor = new Dialog     imgCanvas = Dialog.NewCanvas(500, 500)     imgCanvas.DrawImage(img, 0, 0, 500)          editor.CanvasParameter(imgCanvas)     editor.StringParameter("Description", img.Description)     editor.BooleanParameter("Color", img.IsColor)     editor.BooleanParameter("Black on White", img.IsBlackOnWhite)          if editor.show("Edit User Image for " + img.ID) then           img.Description = editor.StringParameter("Description")           img.IsColor = editor.BooleanParameter("Color")           img.IsBlackOnWhite = editor.BooleanParameter("Black on White")           return true     end if          return falseend functionfunction toStr(b as boolean) as string     if b then           return "true"     else           return "false"     end ifend functionclass ImageMetaData      implements MultiFieldObject     ID as string     Desc as string     isColor as boolean     isBlackOnWhite as boolean     index as integer     function ColumnName(idx as integer) as string           if idx = 1 then                return "ID"           elseif idx = 2 then                return "Description"           elseif idx = 3 then                return "Color"           elseif idx = 4 then                return "Black on White"           elseif idx = 5 then                return "Index"           end if     end function     function ColumnType(idx as integer) as integer           if idx = 1 then                return vtype_String           elseif idx = 2 then                return vtype_String           elseif idx = 3 then                return vtype_Boolean           elseif idx = 4 then                return vtype_Boolean           elseif idx = 5 then                return vtype_Integer           end if     end function     function ColumnValue(idx as integer) as string           if idx = 1 then                return ID           elseif idx = 2 then                return Desc           elseif idx = 3 then                return toStr(isColor)           elseif idx = 4 then                return toStr(isBlackOnWhite)           elseif idx = 5 then                return Str(index)           end if           return "undefined column (" + Str(idx) + ")"     end function     function nColumns() as integer           return 5     end functionend classfunction getImageMetaData(img as Image, idx as integer) as ImageMetaData     dim metadata as ImageMetaData     metadata = new ImageMetaData          metadata.ID = img.ID     metadata.Desc = img.Description     metadata.isColor = img.IsColor     metadata.isBlackOnWhite = img.IsBlackOnWhite     metadata.index = idx          return metadataend functionsub main()try     dim imageData(1000) as ImageMetaData          dim i, idx as integer, img as Image     i = 0     for idx = 1 to Image.Count           img = Image.Get(idx)           if img.IsUser then                imageData(i) = getImageMetaData(img, idx)                i = i + 1           end if     next     redim imageData(i-1)          dim browser as Dialog     while true           browser = new Dialog           browser.ListChoiceParameter("User Images", 0, imageData, true, 50, true)           browser.ParameterWindowNoCancel()           browser.ParameterWindowOKCaption("Done")                      if browser.show("User Image Browser") then                if browser.DoubleClickedList() = "User Images" then                     i = browser.ListChoiceParameter("User Images")                     idx = imageData(i).index                     img = Image.Get(idx)                     if EditImage(img) then                           imageData(i) = getImageMetaData(img, idx)                     end if                else                     return                end if           else                return           end if     wendcatch   print "My bad.  Image Browser script generated an exception."end tryend sub
_______________________________________________
APBeta mailing list
APBeta at lists.astroplanner.net
http://lists.astroplanner.net/listinfo.cgi/apbeta-astroplanner.net 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.astroplanner.net/pipermail/apbeta-astroplanner.net/attachments/20110709/0c5974b7/attachment-0003.htm>


More information about the APBeta mailing list