RAD - Case Study Version 1

David Burgun dburgun at dsl.pipex.com
Sat Mar 25 11:12:15 EST 2006


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





More information about the use-livecode mailing list