Okay, I'll bite. I have just created your version 1. I have not looked
at version 2 yet.
Here is my setup:
1 button: Choose
3 flds: BaseFolder, FolderContents, FileContents
These controls were grouped. No name or custom properties were assigned
to anything. I set the listBehavior of the FolderContents field to true,
and put vertical scrollbars on FolderContents and FileContents. Setup
time: about 1 minute.
Scripts:
** Choose button:
on mouseUp
answer folder "Choose the base folder:"
if it <> "" then setFolder it
end mouseUp
** FolderContents field:
on selectionChanged
putFileContents (the selectedtext of me)
end selectionChanged
** Stack script:
on setfolder tFolder
put the ID of the owner of the target into tGrp
put tFolder into fld "basefolder" of grp ID tGrp
put the directory into tOldDir
set the directory to tFolder
put the files into fld "folderContents" of grp ID tGrp
put "" into fld "fileContents" of grp ID tGrp
set the directory to tOldDir
end setfolder
on putFileContents tFile
put the ID of the owner of the target into tGrp
put fld "basefolder" of grp ID tGrp & slash & tFile into tFilePath
put url ("file:"&tFilePath) into fld "fileContents" of grp ID tGrp
end putFileContents
Comparing our methods:
Thing Mine Yours
# of objects with scripts 3 8
# of custom properties 0 3
# objects with custom props 0 8
Total lines of script 21 63
I will go read what is required for version 2 now.
David Burgun wrote:
-------------
Case Study - Version 1
-------------
I was asked to create an App containing 3 groups (each group is stored
in a "standard" Library and is just pasted into a new stack)
A Group (Group_SelectFolder) that handles the selection of a base folder.
A Group (Group_FileList) that displays the files in a folder selected
by Group_SelectFolder and allows one of them to be seleted.
A Group (Group_FileContents ) that displays the contents of the file
selected in Group_FileList.
The pseudo code (which is actually just a cut down version of the real
code) is shown below.
------------------------------------
Version 1 - Display contents of a file.
Please note that the setting of the CustomProperties "cpFolderKind" and
"cpFileKind" are shown here as being initialized in the Script. In
reality this is commented out and they are set by the developer in the
Property Inspector.
Also note that this uses "me" as in "put empty into me", this causes
problems when sending messages to multiple cards and in the real code
it now reads "set the text of the long id of me to empty". I didn't
bother to change it here as the former style is easier to read.
------------------------------------
Group_SelectFolder
[Label_Selected] [Field_FolderPathName] (Button_Clear)
(Button_Choose)
Script for Group_SelectFolder:
on ISM_InitializeObject
set the cpFolderKind of me to "FolderKindA"
end ISM_InitializeObject
Script for Field_FolderPathName:
on ISM_InitializeObject
put empty into me
get ISM_ListenForMessages("msg_FolderSelected",the cpFolderKind of the
long owner of me)
end ISM_InitializeObject
on msg_FolderSelected theMessageID, theMessageKind, theFolderPathName
put theFolderPathName into me
end msg_FolderSelected
Script for Button_Clear:
on ISM_InitializeObject
get ISM_ListenForMessages("msg_FolderSelected",the cpFolderKind of the
long owner of me)
end ISM_InitializeObject
on msg_FolderSelected theMessageID, theMessageKind, theFolderPathName
if theFolderPathName = empty then disable me else enable me
end msg_FolderSelected
on mouseUp
get ISM_PutMessage("msg_FolderSelected",the cpFolderKind of the long
owner of me, empty)
end mouseUp
Script for Button_Choose:
on mouseUp
answer folder "Select Folder: "
put it into myBaseFolder
if myBaseFolder = empty then exit mouseUp
if char -1 of myBaseFolder <> "/" then
put myBaseFolder & "/" into myBaseFolder
end if
get ISMPutMessage("msg_FolderSelected",the cpFolderKind of the long
owner of me,myBaseFolder)
end mouseUp
Group_FileList
[Field_FileList] [<Field_FilePathNameSelected>]
Script for Group_FileList:
on ISM_InitializeObject
set the cpFolderKind of me to "FolderKindA"
set the cpFileKind of me to "FileKindA"
end ISM_InitializeObject
Script for Field_FileList:
on ISM_InitializeObject
set the cpCurrentFolder of me to empty
get ISM_ListenForMessages("msg_FolderSelected",the cpFolderKind of the
long owner of me)
end ISM_InitializeObject
on msg_FolderSelected theMessageID, theMessageKind,theFolderPathName
put GetFilesFromFolder(theFolderPathName) into me
set hilitedline of me to 1
set the vScroll of me to 0
put line 1 of the text of me into myFileName
get ISM_PutMessage("msg_FileSelected", the cpFileKind of the long owner
of me, theFolderPathName & myFileName)
set the cpCurrentFolder of me to theFolderPathName
end msg_FolderSelected
on mouseUp
put the clickLine into myClickLine
select myClickLine
put line word 2 of myClickLine of the text of me into myFileName
get ISM_PutMessage("msg_FileSelected", the cpFileKind of the long owner
of me, the cpCurrentFolder of me & myFileName)
end mouseUp
Script for Field_FilePathNameSelected:
on msg_FileSelected theMessageID, theMessageKind,theFilePathName
put theFilePathName into me
end msg_FileSelected
Group_FileContents
[<Field_FileContents>]
Script for Group_FileContents:
No Script needed.
Script for Field_FileContents :
on ISM_InitializeObject
get ISM_ListenForMessages("msg_FolderSelected",the cpFolderKind of the
long owner of me)
get ISM_ListenForMessages("msg_FileSelected",the cpFileKind of the long
owner of me)
end ISM_InitializeObject
on msg_FileSelected theMessageID, theMessageKind,theFilePathName
put GetContentsOfFile(theFilePathName) into me
end msg_FileSelected
on msg_FolderSelected theMessageID, theMessageKind,theFolderPathName
put empty into me
end msg_FolderSelected
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
Jacqueline Landman Gay | [EMAIL PROTECTED]
HyperActive Software | http://www.hyperactivesw.com
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution