Thursday, December 04, 2008     Register | Login | Search | Contact Us
     

Many of you already received communications about the move of the Cadence user community into cadence.com. And many of you have already joined, with over 4000 registrations in the first two weeks.

The new Cadence Community enhances the ability of Cadence users to connect and collaborate. In addition to moving the community into cadence.com -- enabling single sign-on for community, Sourcelink and Cadence events -- the new site is organized around nine technology segments, giving you easy access to product information, training, forums and blogs. Some of the new features include:
  • Ability to respond to posts via e-mail
  • Technology-specific blogs
  • Latest Web 2.0 social networking capabilities
  • Public profile options
  • Private messaging
  • Friends lists
Visit the new Cadence Community today at www.cadence.com/community and join the discussions!

Registration note: Due to the scope of the enhancements and the new SSO registration system, we were not able to migrate existing cdnusers.org member accounts. So new registrations are required, but this enables a broader set of functionality we think you'll enjoy.

Forum note: Under the guidance of forum moderators, we have taken the 20+ cdnusers.org forums and consolidated them into 11 forums on the new site. Posts have been brought over so you can leverage that posting history. CDNusers forums will be set to read only starting 7/30, and cdnusers.org will be redirected to the new community on 8/4.

Best regards,
Mike and Tom

Michael A. Catrambone - Steering Committee Chairman
Distinguished Engineer
PCB/Mechanical
UTStarcom, Inc.

Tom Diederich
Cadence Community Manager
Home
Forums
Subject: GUI - Select File Form
Posting to forums is available to community members only.
Login or Register
Rate this topic:
   
Author Messages
miro
Posts: 5
Online: User is Offline
4/03/2008 9:43 AM  
Hello,

In a SKILL program, I would need to let user specify the input file using GUI form, where he can browse the directory structure and select a file. Does some pre-prepared form exist or do I have to make my own using SKILL User Interface functions?
I have searched sourcelink, but found nothing.

Thanks,
Miro
Randy R.
Posts: 52
Online: User is Offline
4/03/2008 9:54 AM  
Try using the axlDMFileBrowse skill command.

G'Day,
adbeckett
Posts: 248
Online: User is Offline
4/03/2008 3:24 PM  
The axlDMFileBrowser would have been fine if this was an SPB forum, because that's for Allegro. But this is a CIC forum, so the question is presumably for DFII.

In ICOA5251 onwards (i.e. IC61 onwards in supported releases), you have hiDisplayFileDialog() which does this. Before that, you'll have to write your own or ask customer support nicely if they can send you one. There's one I wrote included in CCR 502768 (if I have a chance, I'll create a solution for it for sourcelink).

Andrew.
miro
Posts: 5
Online: User is Offline
4/04/2008 4:27 AM  
Thanks a lot for a tip Andrew.
Miro
ahamlett
Posts: 28
Online: User is Offline
6/24/2008 5:18 PM  
Here is a file browser I wrote that you can use:


procedure( browseForFile(@optional (dir nil))
    ; Argument is a file or directory path as string
    prog( (file temp okPressed firstSlash)
        
        ; Check inputs
        if(!stringp(dir) then
            dir = getWorkingDir()
        )
        
        ; Get starting directory
        if(!isDir(dir) then
            if(substring(dir 1 1) == "/" then
                firstSlash = t
            else
                firstSlash = nil
            )
            temp = parseString(dir "/")
            dir = car(temp)
            for(a 1 sub1(sub1(length(temp)))
                dir = strcat(dir "/" nth(a temp))
            )
            if(firstSlash then
                dir = strcat("/" dir)
            )
        )
        
        ; Create form fields
        dir = hiCreateStringField(
            ?name 'dir
            ?value dir
            ?callback "if(isDir(dir->value) then hiDeleteField(browseForFile 'file) file->choices = getDirFiles(dir->value) file->value = list(car(getDirFiles(dir->value))) hiAddField(browseForFile list(file 0:30 400:250 0)))"
        )
        file = hiCreateListBoxField(
            ?name 'file
            ?choices getDirFiles(dir->value)
            ?value list(car(getDirFiles(dir->value)))
            ?multipleSelect nil
            ?doubleClickCB "if(isDir(strcat(dir->value \"/\" car(file->value))) then hiDeleteField(browseForFile 'dir) dir->value = parseDirectory(strcat(dir->value \"/\" car(file->value))) hiAddField(browseForFile list(dir 0:0 400:30 0)) hiDeleteField(browseForFile 'file) file->choices = getDirFiles(dir->value) file->value = list(car(getDirFiles(dir->value))) hiAddField(browseForFile list(file 0:30 400:250 0)) else hiFormDone(browseForFile))"
        )
        
        ; Create form
        okPressed = nil
        hiCreateAppForm(
            ?name 'browseForFile
            ?formTitle "Browse For File"
            ?buttonLayout 'OKCancel
            ?callback "okPressed = t"
            ?fields list(
                list(dir 0:0 400:30 0)
                list(file 0:30 400:250 0)
            )
            ?initialSize t
        )
        hiDisplayForm(browseForFile)
        
        if(okPressed then
            return(sprintf(nil "%s/%s" dir->value car(file->value)))
        else
            return(nil)
        )
    )
)

procedure( parseDirectory(dir)
    prog( (fS arr)
        if(substring(dir 1 2) == ".."
            dir = strcat(getWorkingDir() "/" dir)
        )
        if(substring(dir 1 1) == "/"
            fS = t
        )
        arr = parseString(dir "/")
        dir = car(arr)
        for(a 1 sub1(length(arr))
            if(nth(a arr) != "." && nth(a arr) != ".." && nth((a+1) arr) != ".." then
                dir = strcat(dir "/" nth(a arr))
            )
        )
        if(fS
            dir = strcat("/" dir)
        )
        return(dir)
    )
)

http://83p.unitedti.org
adbeckett
Posts: 248
Online: User is Offline
6/25/2008 12:42 AM  
Alan, it's generally recommended to use a prefix for your function names, and for customer code, it should begin with upper case. It then avoids clashing with any other function parseDirectory, browseForFile etc.

BTW there's actually a built-in browser, even in IC5141 which I hadn't realised at the time I appended before was public. This was added in IC5141 USR4, and is called ddsFileBrowseCB(). For more details see my sourcelink solution number 11457794, as well as the documentation.

Regards,

Andrew.
Tongju
Posts: 13
Online: User is Offline
6/25/2008 10:08 AM  
Hi, Andrew,

For ddsFileBrowseCB(), if I like to control the location of the initial "Current Directory" instead of the default director for the purpose of easy navigation, any easy way to achieve this?

Thanks,

Tongju
adbeckett
Posts: 248
Online: User is Offline
6/26/2008 9:36 AM  
Tongju,

The browser is seeded from any directory that is in the field on your form. So you can do it this way. If the field is blank, it uses the current directory; if not blank, it uses the directory that is the field value.

Andrew.
Tongju
Posts: 13
Online: User is Offline
6/26/2008 11:36 AM  
Thank you, Andrew! It works great! Tongju
ahamlett
Posts: 28
Online: User is Offline
6/26/2008 1:26 PM  
Updated function:



procedure( AHbrowseForFile(@optional (dir nil) (filter nil))
    ; Argument is a file or directory path as string
    prog( (file temp okPressed firstSlash)
        
        ; Check inputs
        if(!stringp(dir) || strlen(dir) == 0 then
            dir = getWorkingDir()
        )
        
        ; Get starting directory
        if(!isDir(dir) then
            if(substring(dir 1 1) == "/" then
                firstSlash = t
            else
                firstSlash = nil
            )
            temp = parseString(dir "/")
            dir = car(temp)
            for(a 1 sub1(sub1(length(temp)))
                dir = strcat(dir "/" nth(a temp))
            )
            if(firstSlash then
                dir = strcat("/" dir)
            )
            if(!isDir(dir) then
                dir = getWorkingDir()
            )
        )
        
        ; Create form fields
        dir = hiCreateStringField(
            ?name 'dir
            ?value dir
            ?callback "if(isDir(dir->value) then hiDeleteField(AHbrowseForFile 'file) file->choices = AHgetFiles(dir->value t \"\\\\.log$\") file->value = list(car(AHgetFiles(dir->value t \"\\\\.log$\"))) hiAddField(AHbrowseForFile list(file 0:30 400:250 0)))"
        )
        file = hiCreateListBoxField(
            ?name 'file
            ?choices AHgetFiles(dir->value t "\\.log$")
            ?value list(car(AHgetFiles(dir->value t "\\.log$")))
            ?multipleSelect nil
            ?doubleClickCB "if(isDir(strcat(dir->value \"/\" car(file->value))) then hiDeleteField(AHbrowseForFile 'dir) dir->value = AHparseDirectory(strcat(dir->value \"/\" car(file->value))) hiAddField(AHbrowseForFile list(dir 0:0 400:30 0)) hiDeleteField(AHbrowseForFile 'file) file->choices = AHgetFiles(dir->value t \"\\\\.log$\") file->value = list(car(AHgetFiles(dir->value t \"\\\\.log$\"))) hiAddField(AHbrowseForFile list(file 0:30 400:250 0)) else hiFormDone(AHbrowseForFile))"
        )
        
        ; Create form
        okPressed = nil
        hiCreateAppForm(
            ?name 'AHbrowseForFile
            ?formTitle "Browse For File"
            ?buttonLayout 'OKCancel
            ?callback "okPressed = t"
            ?fields list(
                list(dir 0:0 400:30 0)
                list(file 0:30 400:250 0)
            )
            ?initialSize t
        )
        hiDisplayForm(AHbrowseForFile)
        
        if(okPressed then
            return(sprintf(nil "%s/%s" dir->value car(file->value)))
        else
            return(nil)
        )
    )
)

procedure( AHgetFiles(directory @optional (sort nil) (filter nil))
    prog( (allFiles file myFiles)
        if(stringp(directory) then
            allFiles = getDirFiles(directory)
            if(stringp(filter) then
                rexMagic(t)
                rexCompile(filter)
                myFiles = allFiles
                allFiles = nil
                foreach(file myFiles
                    if(isDir(strcat(directory "/" file)) || rexExecute(file) then
                        allFiles = cons(file allFiles)
                    )
                )
                reverse(allFiles)
            )
            if(sort
                allFiles = sort(allFiles nil)
            )
        )
        return(allFiles)
    )
)

procedure( AHparseDirectory(dir)
    prog( (fS arr)
        if(substring(dir 1 2) == ".."
            dir = strcat(getWorkingDir() "/" dir)
        )
        if(substring(dir 1 1) == "/"
            fS = t
        )
        arr = parseString(dir "/")
        dir = car(arr)
        for(a 1 sub1(length(arr))
            if(nth(a arr) != "." && nth(a arr) != ".." && nth((a+1) arr) != ".." then
                dir = strcat(dir "/" nth(a arr))
            )
        )
        if(fS
            dir = strcat("/" dir)
        )
        return(dir)
    )
)

Andrew, what are the two arguments expected when calling ddsFileBrowseCB()? It seems to want a string as arg 0 and a form symbol as arg 1 but the form needs a certain field to be defined.

http://83p.unitedti.org
adbeckett
Posts: 248
Online: User is Offline
6/26/2008 2:24 PM  
The first argument is not a string. It's a form object. It's

ddsFileBrowseCB(form 'fieldName)

e.g.

ddsFileBrowseCB(hiGetCurrentForm() 'fileNameField)

The solution I mention above gives an example. It's also covered in (at least) the IC612 documentation. Not checked - perhaps it didn't make it into the IC5141 docs since it got added only in a USR.

Regards,

Andrew.
ahamlett
Posts: 28
Online: User is Offline
6/27/2008 11:51 AM  
Thanks Andrew!

http://83p.unitedti.org
ahamlett
Posts: 28
Online: User is Offline
7/01/2008 10:42 AM  
Does anyone have a better way of updating form fields instead of deleting and adding them back?

http://83p.unitedti.org
dmay
Posts: 29
Online: User is Offline
7/01/2008 10:47 AM  
Do you mean:

formId->fieldName->value = newValue

ahamlett
Posts: 28
Online: User is Offline
7/01/2008 11:08 AM  
Ok nevermind for some reason my fields weren't updating in the form when I changed the value. Thanks dmay!

http://83p.unitedti.org
ahamlett
Posts: 28
Online: User is Offline
7/01/2008 12:04 PM  
Does anyone know how to add/remove fields from a scroll region?

http://83p.unitedti.org
adbeckett
Posts: 248
Online: User is Offline
7/01/2008 12:55 PM  
Normally hiAddField and hiDeleteField take a form as the first argument. Instead you can pass them the scroll region as the first argument - and thus you can add or delete fields into/from the scroll region.

Regards,

Andrew.
Posting to forums is available to community members only.
Login or Register

Forums > Custom IC > Shared code - SKILL > GUI - Select File Form


ActiveForums 3.6
     
Copyright 2006 Cadence Design Systems, Inc.