Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SKILL function for directory browsing

2,225 views
Skip to first unread message

Alexey

unread,
Mar 24, 2003, 3:00:13 PM3/24/03
to
I need to select some file.
there is standart fucnction? or I must Ireate my own script for file navigation

Andrew Beckett

unread,
Mar 24, 2003, 7:01:25 PM3/24/03
to
No standard function for this, unfortunately. Writing your own isn't hard
though.
Something it would be nice to have, and I'm sure there are enhancement
requests for. I wrote one a few years ago in such a way I could link it
into whatever form I needed it with, so having done it once,
it's not a big problem.

Andrew.


On 24 Mar 2003 12:00:13 -0800, lohm...@mail.ru (Alexey) wrote:

>I need to select some file.
>there is standart fucnction? or I must Ireate my own script for file navigation

--
Andrew Beckett
Senior Technical Leader
Custom IC Solutions
Cadence Design Systems Ltd

Mark Valery

unread,
Mar 24, 2003, 11:04:42 PM3/24/03
to
On Mon, 24 Mar 2003 12:00:13 +0000, Alexey wrote:

> I need to select some file.
> there is standart fucnction? or I must Ireate my own script for file navigation

This is some old ae ware from the pre 4.4 days. I started hacking it
to do what I want, not to sure if it still works because I went on to
other projects.

/*
File Name : unixBrowser.il
Function Name : ufbSyncField
Title : Creates an CustomMenu in the CIW Banner
Author : Hinson Stephens Orlando,Fl
Date : 5/16/94
Revision : 1.0
SW Release : 4.3
Prerequisites : None
Synopsis : ufbSyncField(?form userForm ?field fieldSymbol) => t/nil
Description :
Functions similar to the Library Browser, it attaches a Unix File
Browser form to the field of a form. To make it work, You just
create a button field that has a callback that calls ufbSyncField.
See the example below, ufbEditUnixFile().
Returns nil if userForm does not exist or fieldSymbol does not exist on form.

The attached skill code implements a Unix File Browser. It is very
similar to the Library Browser in that it updates a form string field
dynamically as things are picked. A minimum invocation for the
browser:

ufbSyncField(?form formVariable ?field form-field-Symbol)

This invokes the Browser, using getWorkingDir() as the initial path.
Other parameters are:

?path - Initial path Displayed.
?numRows - integer, number of rows of files to display
?permDirList - List of directories that are always available to go to
?fileFilter - Only files that match expression are displayed - needs work
?initialFile - not implemented yet
?formLabel - Label on top of Browser Form
?pathLabel - Label for Path field on Browser form
?fileLabel - Label for File field on Browser form

There are basically two list fields on the form, one for the
directories to pick from, and the other for files in the current
directory that match the fileFilter (if non-blank). The directory
list, maintains a list of all visited (and ?permDirList) directories.
Below this is ".." and the list of directories that exist under the
current directory.

There is an example application of this code that allows a user to Edit
a Unix File. This is at the end of the file. If you have my "Custom
Menu" code loaded, a menu item will be added to it to allow you to
invoke the "Edit Unix File", otherewise, just type

ufbEditUnixFileUI()

into the CIW after loading this code.

Modification history :
(name) (date) (changes)
HLS 5/16/94 First implementation

*/

; Returns a full pathName for pathString using basePath as
; the base in case pathString is relative.(i.e. starts with / or ~)
; basePath should be a full path or ot will be interpreted as
; relative to getWorkingDir();

procedure(ufbFullPath(basePath pathString) ;_Feb 3 03 mev 181
let((fullPath)
if(member(substring(pathString 1 1) list("/" "~")) then
fullPath = simplifyFilename(pathString)
basePath = ""
else
unless(basePath
basePath = getWorkingDir()
)
fullPath = simplifyFilename(strcat(basePath "/" pathString))
) ; ** if member **
; when(strlen(rindex(fullPath "/")) == 1
; ;when(substring(fullPath strlen(fullPath) 1) == "/" ;)
; fullPath = substring(fullPath 1 strlen(fullPath) - 1)
; )
fullPath
) ; ** let **
) ; ** procedure ufbFullPath **

; removes one segment of a pathname (plus any trailing "/")
procedure(ufbUtilRemoveFilePathSegment(filePath) ;_Feb 3 03 mev 262
let((fullPath path newPath)
fullPath = ufbFullPath(nil filePath)
path = parseString(fullPath "/")
newPath = ""
for( i 0 length(path)-2
newPath = strcat(newPath "/" nth(i path))
)
when( newPath == "" newPath = "/"
)
newPath
; if(rindex(fullPath "/") then
; if( fullPath == "/" then
; path = "/"
; else
; path = substring(fullPath 1 strlen(fullPath)-strlen(rindex(fullPath "/")))
; )
; when( path = "" path = "/" )
; else
; path = ""
; ) ; ** if rindex **
; path
) ; ** let **
) ; ** procedure ufbUtilRemoveFilePathSegment **

; Callback for user manually entering a path into the File Path Field
; not currently implemented due to infinite loop problem.
procedure(ufbFilePathCB(ufbForm) ;_Feb 3 03 mev 185
let((ufbPath)
ufbPath = get(get(eval(ufbForm) 'filePathFF) 'value)
ufbGetDirFileLists(ufbForm ufbFullPath(nil ufbPath))
)
) ; ** procedure ufbFilePathCB **

; Callback for a change to the dirListBoxFF field (i.e. user picked a directory)
procedure(ufbDirListBoxChangeCB(ufbForm) ;_Feb 3 03 mev 644
let((selectedFile ufbPath ufbOldPath dirFileLists userForm userField)
ufbOldPath = get(get(eval(ufbForm) 'filePathFF) 'value)
ufbPath = ufbOldPath
printf("ufbPath1:%L\n" ufbPath)
userForm = get(eval(ufbForm) 'userForm)
userField = get(eval(ufbForm) 'userField)
selectedFile = get(get(eval(ufbForm) 'dirListBoxFF) 'value)
printf("selectedFile:%L\n" selectedFile)
when(selectedFile
selectedFile = car(selectedFile)
if(selectedFile == ".." then
ufbPath = ufbUtilRemoveFilePathSegment(ufbPath)
else
ufbPath = ufbFullPath(ufbPath selectedFile)
)
) ; ** when selectedFile **
printf("ufbPath2:%L\n" ufbPath)
dirFileLists = ufbGetDirFileLists(ufbForm ufbPath)
; Update DirListBox choices on Form
putprop(get(eval(ufbForm) 'dirListBoxFF) car(dirFileLists) 'choices)
; Update FileListBox choices on Form
putprop(get(eval(ufbForm) 'fileListBoxFF) cadr(dirFileLists) 'choices)
; Clear FileListBox value on Form
putprop(get(eval(ufbForm) 'fileListBoxFF) nil 'value)
; Update FilePath value on Form
putprop(get(eval(ufbForm) 'filePathFF) ufbPath 'value)
when(!member(get(get(eval(ufbForm) 'fileNameFF) 'value)
cadr(dirFileLists))
putprop(get(eval(ufbForm) 'fileNameFF) "" 'value)
)
putprop(get(eval(userForm) userField)
strcat(ufbPath "/" get(get(eval(ufbForm) 'fileNameFF) 'value))
'value)
) ; ** let **
) ; ** procedure ufbDirListBoxChangeCB **

; Callback for a change to fileListBoxFF, (i.e. user picked a fileName)
procedure(ufbFileListBoxChangeCB(ufbForm) ;_Feb 3 03 mev 0
let((value userForm userField ufbPath)
ufbPath = get(get(eval(ufbForm) 'filePathFF) 'value)
userForm = get(eval(ufbForm) 'userForm)
userField = get(eval(ufbForm) 'userField)
value = get(get(eval(ufbForm) 'fileListBoxFF) 'value)
when(value
putprop(get(eval(ufbForm) 'fileNameFF) car(value) 'value)
)
putprop(get(eval(userForm) userField)
strcat(ufbPath "/" get(get(eval(ufbForm) 'fileNameFF) 'value))
'value)
) ; ** let **
) ; ** procedure ufbFileListBoxChangeCB **

procedure(ufbCheckRexExp(rexExp) ;_Feb 3 03 mev 0
let((newRex prev char)
newRex = ""
for(i 1 strlen(rexExp)
char = substring(rexExp i 1)
if(char == "*" then
if(prev != "." then
newRex = strcat(newRex ".")
)
)
newRex = strcat(newRex char)
prev = char
) ; ** for i **
newRex
) ; ** let **
) ; ** procedure ufbCheckRexExp **

; Updates ufb form based on a change to the current path
procedure(ufbGetDirFileLists(ufbForm currentPath) ;_Feb 3 03 mev 311
prog((currentDirFiles dirDirList dirFileList dirMatchList permDirList filter)
; Get permanent list of directories (initial + visited)
permDirList = get(eval(ufbForm) 'permDirList)
when(isDir(currentPath)
printf("currentPath:%L\n" currentPath)
dirDirList = nil
dirFileList = nil
currentDirFiles = getDirFiles(currentPath)
; Changed 4 lines commented below to next section, trying for performance
foreach(file currentDirFiles
unless( currentPath == "/" && file == ".."
if(isDir(ufbFullPath(currentPath file)) then
dirDirList = cons(file dirDirList)
else
dirFileList = cons(file dirFileList)
)
) ; ** unless currentPath **
) ; ** foreach file **
dirDirList = sort(dirDirList 'alphalessp)
dirFileList = sort(dirFileList 'alphalessp)
printf("dirDirList: %L\ndirFileList: %L\n" dirDirList dirFileList)
; dirDirList = sort( setof(file dirFileList
; isDir(ufbFullPath(currentPath file))) 'alphalessp)
; dirFileList = sort( setof(file dirFileList
; isFile(ufbFullPath(currentPath file))) 'alphalessp)
dirDirList = remove("." dirDirList)
; Add each dir in permDirList to dirDirList if not already on
foreach(dir permDirList
unless(member(dir dirDirList)
dirDirList = cons(dir dirDirList)
)
)
; Add currentPath to dirDirList if not already on
unless(member(currentPath dirDirList)
dirDirList = cons(currentPath dirDirList)
)
; Add currentPath to permDirList if not already on
unless(member(currentPath permDirList)
permDirList = append(permDirList list(currentPath))
)
; Update permDirList property on Form
putprop(eval(ufbForm) permDirList 'permDirList)
unless(dirFileList
dirFileList = list("")
)
filter = ufbCheckRexExp(get(get(eval(ufbForm) 'fileFilterFF) 'value))
if(filter && filter != "" then
unless(errset(rexCompile(filter))
printf("** WARNING -> Bad filter specified\n")
return(list(dirDirList dirFileList))
)
dirMatchList = setof(file dirFileList rexExecute(file))
if(dirMatchList then
return(list(dirDirList dirMatchList))
else
return(list(dirDirList list("")))
)
else
return(list(dirDirList dirFileList))
) ; ** if filter **
) ; ** when isDir **
) ; ** prog **
) ; ** procedure ufbGetDirFileLists **


; Main entry point , creates form with and sets initial "path" and choices
; and syncs field on form with user specified field. If filePath is a dir (i.e.
; no fileName was chosen then the filePath will end with a slash.
procedure(ufbSyncField(@key form field (path ".") ;_Feb 3 03 mev 0
initialFile (fileFilter "") permDirList (numRows 20)
formLabel pathLabel fileLabel)
prog((dirFileLists ufbForm)
; form and field must exist
unless(boundp('form) && hiIsForm(form)
printf("** Warning ** => User form(%s) does not exist\n" get_pname(form))
return(nil)
)
unless(get(form field)
printf("** Warning ** => (%s) is not a valid field on form(%s)\n"
field form->hiFormSym)
return(nil)
)
; path is optional and defaults to "."
unless(path
path = "."
)
path = ufbFullPath(nil path)

; Creates form with same name as users form only adds UFB to the symbol name
ufbForm = concat(form->hiFormSym "UFB")
ufbCreateForm(ufbForm numRows fileFilter formLabel pathLabel fileLabel)

; add properties to form for callbacks to no which formField to update
putprop(eval(ufbForm) permDirList 'permDirList)
putprop(eval(ufbForm) form 'userForm)
putprop(eval(ufbForm) field 'userField)

; Update file filter field
putprop(get(eval(ufbForm) 'fileFilterFF) fileFilter 'value)

; Get current file lists to update form
dirFileLists = ufbGetDirFileLists(ufbForm path)

; Update DirListBox choices on Form
putprop(get(eval(ufbForm) 'dirListBoxFF) car(dirFileLists) 'choices)
; Update FileListBox choices on Form
putprop(get(eval(ufbForm) 'fileListBoxFF) cadr(dirFileLists) 'choices)
; Clear FileListBox value on Form
putprop(get(eval(ufbForm) 'fileListBoxFF) nil 'value)
; Update FilePath value on Form
putprop(get(eval(ufbForm) 'filePathFF) path 'value)

; Display the Unix File Browser form
hiDisplayForm(ufbForm)
return(t)
) ; ** prog **
) ; ** procedure ufbSyncField **


; Creates the initial File Browser form, initialization is done afterwards.
;... ufbCreateForm ............ Dec 22 95 valery 2371

procedure(ufbCreateForm(ufbForm numRows fileFilter formLabel pathLabel fileLabel ) ;_Feb 3 03 mev 0
prog((filePathFF fileNameFF fileFilterFF dirListBoxFF fileListBoxFF
pathLabelFF fileLabelFF strH strY listH lBoxY dirX dirW fileX fileW)
unless(boundp(ufbForm) && ufbForm
unless(formLabel
formLabel = "Unix File Browser"
)
unless(pathLabel
pathLabel = "Unix File Path"
)
unless(fileLabel
fileLabel = "Unix File Name"
)

filePathFF = hiCreateStringField(
?name 'filePathFF
?prompt ""
?help ""
?value ""
)
fileNameFF = hiCreateStringField(
?name 'fileNameFF
?prompt ""
?help ""
)
dirListBoxFF = hiCreateListBoxField(
?name 'dirListBoxFF
?choices list("");
?prompt ""
?value nil
?callback ""
?changeCB "ufbDirListBoxChangeCB(ufbForm)"
?numRows numRows
;[?multipleSelect g_multipleSelect ]
;?doubleClickCB "ufbDirListBoxChangeCB(ufbForm)"
)
fileFilterFF = hiCreateStringField(
?name 'fileFilterFF
?prompt "Filter"
?help ""
?value fileFilter
?callback "ufbDirListBoxChangeCB(ufbForm)"
)
fileListBoxFF = hiCreateListBoxField(
?name 'fileListBoxFF
?choices list("")
?prompt ""
?value nil
?callback ""
?changeCB "ufbFileListBoxChangeCB(ufbForm)"
?numRows numRows-2
;[?multipleSelect g_multipleSelect ]
;?doubleClickCB "ufbFileListBoxChangeCB(ufbForm)"
)
pathLabelFF = hiCreateLabel(
?name 'pathLabelFF
?labelText pathLabel
)
fileLabelFF = hiCreateLabel(
?name 'fileLabelFF
?labelText fileLabel
)
strH = 35
strY = 35
listH = 17
lBoxY = strH + strY
dirX = 10
dirW = 450
fileX = dirW+40
fileW = 300
ufbForm = hiCreateAppForm(
?name ufbForm
?formTitle formLabel
?callback ""
;?dialogStyle 'modal
?initialSize fileW+dirW+130:numRows*listH+80+lBoxY
?fields list(
list(pathLabelFF dirX:0 dirW:strH)
list(fileLabelFF fileX:0 fileW:strH)
list(filePathFF dirX:strY dirW:strH 0)
list(fileNameFF fileX:strY fileW:strH 0)
list(dirListBoxFF dirX:lBoxY dirW:numRows*listH+20 0)
list(fileFilterFF fileX:lBoxY fileW:2*listH 35)
list(fileListBoxFF fileX:lBoxY+2*listH fileW:(numRows-2)*listH+20 0)
)
)
hiSetFieldEditable(get(ufbForm 'filePathFF) nil)
hiSetFieldEditable(get(ufbForm 'fileNameFF) nil)
; hiSetFieldEditable(get(ufbForm 'fileNameFF) t)
) ; ** unless boundp **
) ; ** prog **
) ; ** procedure ufbCreateForm **


; The rest of this file is an implementation of an application that might
; use the Unix File Browser, it provides a form with a Browse button
; that allows a user to pick a file to edit.

procedure(ufbCreateEditUnixFileForm() ;_Feb 3 03 mev 0
let((ufbUnixFilenameFF ufbUnixBrowseButton)
ufbUnixFilenameFF = hiCreateStringField(
?name 'ufbUnixFilenameFF
?prompt "File to Edit"
?help ""
?value ""
)
ufbUnixBrowseButton = hiCreateButton(
?name 'ufbUnixBrowseButton
?buttonText " Unix Browse "
?callback "ufbSyncField(?form ufbEditForm ?field 'ufbUnixFilenameFF ?numRows 20)"
)

ufbEditForm = hiCreateAppForm(
?name 'ufbEditForm
?formTitle "Edit Unix File"
?callback "ufbEditUnixFileFCB()"
;?initialSize fileW+dirW+130:numRows*listH+80+lBoxY
?fields list(
list(ufbUnixFilenameFF 0:0 500:35 0)
list(ufbUnixBrowseButton 500:0 100:35)
)
)
) ; ** let **
) ; ** procedure ufbCreateEditUnixFileForm **


procedure(ufbEditUnixFileFCB() ;_Feb 3 03 mev 0
when(editor == "vi"
editor = "xterm -e vi"
)
when(isFile(ufbEditForm->ufbUnixFilenameFF->value)
system(sprintf(nil "%s %s" editor
ufbEditForm->ufbUnixFilenameFF->value))
)
) ; ** procedure ufbEditUnixFileFCB **


procedure(ufbEditUnixFileUI() ;_Feb 3 03 mev 0
unless(boundp('ufbEditForm)
ufbCreateEditUnixFileForm()
)
hiDisplayForm(ufbEditForm)
) ; ** procedure ufbEditUnixFileUI **


; Check to see if user is using the Custom Menu, if so, create a menu and add it
; the Custom Menu to invoke this tool.
when(boundp('hlsCustomMenu)
unless(boundp('ufbEditUnixFileMI)
ufbEditUnixFileMI = hiCreateMenuItem(
?name 'ufbEditUnixFileMI
?itemText "Edit Unix File"
?callback "ufbEditUnixFileUI()"
)
hlsAddToCustomMenu('ufbEditUnixFileMI)
) ; ** unless boundp **
) ; ** when boundp **


John Gianni

unread,
Mar 26, 2003, 3:29:24 AM3/26/03
to
"Mark Valery" <meva...@attbi.com> provided the SKILL program:
> File Name : unixBrowser.il

> Date : 5/16/94
> Revision : 1.0
> SW Release : 4.3

1. Interestingly, this is a very well written program, which has been
forwarded within Cadence for a few years now under a few names, e.g.,
MyUnixBrowse.il, unixBrowse.il, unixBrowser.il, etc.; and which has
been updated by SKILL luminaries such as Alan Barclay & Yukio Yoshida
in addition to Hinson Stevens, over the years.

2. I ran a quick 5-minute SKILL survey (available in the latest IC50
release as part of the product 900 SKILL Development Environment Toolbox).

54 Cadence public functions were called; 12 user-defined functions were
called (two of which are apparently un-defined).

3. A quick summary of a static (non-dynamic) test of the src:
- There are no private (undocumented, unsupported) functions used.
- There are no deleted functions used in this code.
- There are no re-defined Cadence functions used in this code.
- Of the dozen Cadence functions which changed between releases,
all appear to be EC (enhancements, compatible) designations.
- Of the 12 user-defined functions, these two appear undefined:
ufbCreateEditUnixFileForm ufbCreateForm

I sent Mark Valery the complete tarkit of point-and-clickable HTML results
describing each function used, its arguments, the changes over time,
the magnitude of the changes, the status of each function, etc.
--
ALL my USENET posts are PERSONAL opinion; none are company statements!

0 new messages