File Directory as a Variable

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf File Directory as a Variable

  • Creator
    Topic
  • #55086
    Jon Melin
    Participant

      Hello,

      I was curious if anyone had an example or an idea of how to use a directory name as a variable. Basically, I’m looking to have Cloverleaf monitor a directory that has a bunch of sub folders in it and when a file shows up in any of those sub folders to do something to that file, and output it to the same folder, but in another OUT directory.

      So essentially there is an In folder with sub directories and an Out folder with sub directories.

      If the directory that’s in the In folder is labeled 1234, I want to append 1234 to ISA 8 in any file in that directory (working with X12 envelope), and put it in the out directory labeled out/1234.

      I have a script I wrote to do the editing of the ISA, I’m essentially looking for a way to monitor MANY sub directories at the same time, take the sub directory name in as a variable, do something based on that name (via if/for or switch or something), and output it to the matching OUT sub directory. Example:

      Input In1234 –> Append ISA8 with 1234 –> Output folder Out1234

      Input Inabc1 –> Append ISA8 with abc1 –> Output folder Outabc1

      Input Inblah –> Append ISA8 with blah –> Output folder Outblah

      Any thoughts?

    Viewing 0 reply threads
    • Author
      Replies
      • #84034
        Charlie Bursell
        Participant

          You could do it by using your own UPoC protocol like:

          proc findfile { dir fname } {

             if {

                 [llength [set x [glob -nocomplain -dir $dir $fname]]]

             } {

                 return [lindex $x 0]

             } else {

                 foreach i [glob -nocomplain -type d -dir $dir *] {

                     if {

                         $i != $dir &&

                         [llength [set x [findfile $i $fname]]]

                     } {

                         return $x

                     }

                 }

             }

          }

          example:

          findfile $::HciSiteDir cbtest.log

          >> C:/cloverleaf/cis6.1/integrator/cbtest/exec/processes/cbtest/cbtest.log

          findfile $::HciSiteDir foobar.log

          >>

          FWIW proc is from the WIKI

      Viewing 0 reply threads
      • The forum ‘Cloverleaf’ is closed to new topics and replies.