Home > Community > Forums > Custom IC SKILL > GUI - Select File Form

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 GUI - Select File Form  

Last post Thu, Apr 3 2008 9:43 AM by archive. 16 replies.
Started by archive 03 Apr 2008 09:43 AM. Topic has 16 replies and 7015 views
Page 1 of 2 (17 items) 1 2 Next >
Sort Posts:
  • Thu, Apr 3 2008 9:43 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    GUI - Select File Form Reply

    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


    Originally posted in cdnusers.org by miro
    • Post Points: 0
  • Thu, Apr 3 2008 9:54 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: GUI - Select File Form Reply

    Try using the axlDMFileBrowse skill command.


    Originally posted in cdnusers.org by Randy R.
    • Post Points: 0
  • Thu, Apr 3 2008 3:24 PM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: GUI - Select File Form Reply

    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.


    Originally posted in cdnusers.org by adbeckett
    • Post Points: 0
  • Fri, Apr 4 2008 4:27 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: GUI - Select File Form Reply

    Thanks a lot for a tip Andrew.
    Miro


    Originally posted in cdnusers.org by miro
    • Post Points: 0
  • Tue, Jun 24 2008 5:18 PM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: GUI - Select File Form Reply

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


    Originally posted in cdnusers.org by ahamlett
    • Post Points: 0
  • Wed, Jun 25 2008 12:42 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: GUI - Select File Form Reply

    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.


    Originally posted in cdnusers.org by adbeckett
    • Post Points: 0
  • Wed, Jun 25 2008 10:08 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: GUI - Select File Form Reply

    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


    Originally posted in cdnusers.org by Tongju
    • Post Points: 0
  • Thu, Jun 26 2008 9:36 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: GUI - Select File Form Reply

    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.


    Originally posted in cdnusers.org by adbeckett
    • Post Points: 0
  • Thu, Jun 26 2008 11:36 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: GUI - Select File Form Reply

    Thank you, Andrew! It works great! Tongju


    Originally posted in cdnusers.org by Tongju
    • Post Points: 0
  • Thu, Jun 26 2008 1:26 PM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: GUI - Select File Form Reply

    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.


    Originally posted in cdnusers.org by ahamlett
    • Post Points: 0
  • Thu, Jun 26 2008 2:24 PM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: GUI - Select File Form Reply

    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.


    Originally posted in cdnusers.org by adbeckett
    • Post Points: 0
  • Fri, Jun 27 2008 11:51 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: GUI - Select File Form Reply

    Thanks Andrew!


    Originally posted in cdnusers.org by ahamlett
    • Post Points: 0
  • Tue, Jul 1 2008 10:42 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: GUI - Select File Form Reply

    Does anyone have a better way of updating form fields instead of deleting and adding them back?


    Originally posted in cdnusers.org by ahamlett
    • Post Points: 0
  • Tue, Jul 1 2008 10:47 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: GUI - Select File Form Reply

    Do you mean:

    formId->fieldName->value = newValue


    Originally posted in cdnusers.org by dmay
    • Post Points: 0
  • Tue, Jul 1 2008 11:08 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: GUI - Select File Form Reply

    Ok nevermind for some reason my fields weren't updating in the form when I changed the value. Thanks dmay!


    Originally posted in cdnusers.org by ahamlett
    • Post Points: 0
Page 1 of 2 (17 items) 1 2 Next >
Sort Posts:
Started by archive at 03 Apr 2008 09:43 AM. Topic has 16 replies.