question about the sysfiletree in sysfile utils.

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

question about the sysfiletree in sysfile utils.

kenner

I copied the code for SysFileTree and FileTree into a new file that I want to work to just find a file and return the name to me.

I guess I just don’t understand “type casting” and passing values back and forth to called methods.

In this code it looks like the stem is returned from FileTree to SysFileTree and then SysFileTree returns it again. And even though I trace it in detail I can’t figure out what is really getting returned. Should I try to use these system utilities as is and just call them from the jar file?

 

And how can this possibly work:???

 

stem[stem[0]] = files[i].toString()

 

Any tips or education appreciated.

 

/**

* Searches a directory for files

*

* @param spec     file search specification

* @param stem     stem with found results (date, time, size, attributes and file specification)

attributes ADHRS Archive Directory Hidden Readonly System,  . not applicable (A and S), + set, - not set

* @param options       combination of F (files only) D (directories only) B (both, default) S (recursive search)

*                                                          T (time format YY/MM/DD/HH/MM) L (time format YYYY-MM-DD HH:MM:SS) I (search case-insensitive) O (fully qualified file name only)

* @param tattrib  target attribute mask ADHRS (* any state, + set, - not set)

* @param nattrib  NOT IMPLEMENTED new attribute mask to set for found files ADHRS (* unchanged, + set, - not set)

* @return         stem

*                                 

* Note : target attributes are verified by IsDirectory, isHidden, canWrite java calls, not by the actual 'attributes', archive and system attributes are not checked

*/

import java.text

import java.util.concurrent

class SysFileTree

            Properties static public

                        Debug_Level = 50

                        spec1 = string

--                      stem1 = string

                        options1 = string

                        tattrib1 = string

                        nattrib1 = string

            trace methods

method main(arg=String[]) static public        

            if Debug_Level > 10 then trace results

            if Debug_Level > 10 then trace var spec1 stem1 options1 tattrib1 nattrib1 d f

            if arg.length = 0 then do

                say '# Please specify file name and directory'

                exit 1

            end

--          parse arg spec1 "," stem1 "," options1 "," tattrib1 "," nattrib1

            argIn = arg[0]

            loop letterNum = 1 by 1 to arg.length - 1

                        argIn = argIn || arg[letterNum]

            end

            say "arg = argIn ==>" argIn

            parse argIn spec1 "," stem1 "," options1 "," tattrib1 "," nattrib1

            say  "spec1 stem1 options1 tattrib1 nattrib1"

            say   spec1 stem1 options1 tattrib1 nattrib1

            say "stem" SysFileTree(spec1, stem1, options1, tattrib1, nattrib1)

--          say stem1.toString()

            return

method SysFileTree(spec, stem, options = 'BL', tattrib = '*****', nattrib = '*****')

            if Debug_Level > 10 then trace results

            if Debug_Level > 20 then trace var d f spec1 stem options1 tattrib1 nattrib

    stem = ''

    stem[0] = 0

    do

       d = spec.substr(1, spec.lastpos('/'))

       f = spec.substr(spec.lastpos('/') + 1)

       regex = f

 

       escapechar = char[] "\\+()^$.{}[]|"

       Loop i = 0 to escapechar.length - 1

          pos = regex.pos(escapechar[i], 1)

          Loop while pos > 0

             regex = regex.insert('\\', pos - 1)

             pos = regex.pos(escapechar[i], pos + 2)

          End

       End

       pos = regex.pos('*', 1)

       Loop while pos > 0

          regex = regex.insert('.', pos - 1)

          pos = regex.pos('*', pos + 2)

       End

       regex = regex.translate('.', '?')

 

       Recursive = 0

       if options.upper.pos('S') > 0 then do

          Recursive = 1

       end

 

       if options.upper.pos('I') > 0 then do

          regex = regex.insert('(?i)')

       end

 

       FileAndOrDir = 'B'

       if options.upper.pos('F') > 0 then do

          FileAndOrDir = 'F'

       end

       if options.upper.pos('D') > 0 then do

          FileAndOrDir = 'D'

       end

 

       if options.upper.pos('T') > 0 then do

          format = SimpleDateFormat("yy/MM/dd/HH/mm")

       end

       else do

          if options.upper.pos('L') > 0 then do

             format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")

          end

          else do

             format = SimpleDateFormat()

          end

       end

 

       FilenameOnly = 0

       if options.upper.pos('O') > 0 then do

          FilenameOnly = 1

       end

 

       stem = FileTree(stem, d, regex, Recursive, FileAndOrDir, format, FilenameOnly, tattrib)

    catch IOException

       stem = ''

       stem[0] = 0

    end

    return this

/**

* Private recursively searches a directory for files

*

* @param stem          stem to fill

* @param dirname       directory to start from

* @param regex         regular expression of file to loop for

* @param Recursive     descend recursively into directories

* @param FileAndOrDir  FDB, File Directory or Both

* @param format        SimpleDateFormat

* @param FileNameOnly  format of returned stem, filename only or datetime size .HDR. filename

* @param tattrib       target attributes mask to match .DHR. (* any state, + set, - not set, . not applicable)

* @return         stem

*

*/

  method FileTree(stem, dirname, regex, Recursive, FileAndOrDir, format = SimpleDateFormat, FilenameOnly, tattrib) private signals IOException

    If Debug_Level > 40 then trace results

    If Debug_Level > 40 then trace var stem dirname regex Recursive FileAndOrDir format FilenameOnly tattrib

    dir = File(dirname)

 

    files = File[] dir.listFiles()

    if files <> null then do

       Loop i = 0 to files.length - 1

          f = Rexx files[i].toString()

          say "f" f

          f = f.substr(f.lastpos('/') + 1)

          say "f" f

          isDirectory = files[i].isDirectory()

          say "f.toString()" f.toString()

          if f.toString().matches(regex)  then do

             addToStem = 0

             if FileAndOrDir == 'B' then do

                addToStem = 1

             end

             if FileAndOrDir == 'F' then do

                if \ isDirectory then do

                   addToStem = 1

                end

             end

             if FileAndOrDir == 'D' then do

                if isDirectory then do

                   addToStem = 1

                end

             end

             if addToStem then do

                if FileNameOnly then do

                   stem[0] = stem[0] + 1

                   stem[stem[0]] = files[i].toString()

                end

                else do

                   epoch = files[i].lastModified()

                   cal = Calendar.getInstance()

                   cal.setTimeInMillis(epoch)

 

                   filedate = Rexx format.format(cal.gettime())

                   if isDirectory then do

                      filesize = '0'

                   end

                   else do

                      filesize = Rexx files[i].length()

                   end

 

                   attrib = '.'

                   if isDirectory then do

                      attrib = attrib'D'

                   end

                   else do

                      attrib = attrib'-'

                   end

                   if files[i].isHidden() then do

                      attrib = attrib'H'

                   end

                   else do

                      attrib = attrib'-'

                   end

                   if files[i].canWrite() then do

                      attrib = attrib'-'

                   end

                   else do

                      attrib = attrib'R'

                   end

                   attrib = attrib'.'

                   if tattrib <> '*****' then do

                      if tattrib.substr(2, 1) == '+' & attrib.substr(2, 1) <> 'D' then do

                         addToStem = 0

                      end

                      else do

                         if tattrib.substr(2, 1) == '-' & attrib.substr(2, 1) <> '-' then do

                            addToStem = 0

                         end

                      end

                      if tattrib.substr(3, 1) == '+' & attrib.substr(3, 1) <> 'H' then do

                         addToStem = 0

                      end

                      else do

                         if tattrib.substr(3, 1) == '-' & attrib.substr(3, 1) <> '-' then do

                            addToStem = 0

                         end

                      end

                      if tattrib.substr(4, 1) == '+' & attrib.substr(4, 1) <> 'R' then do

                         addToStem = 0

                      end

                      else do

                         if tattrib.substr(4, 1) == '-' & attrib.substr(4, 1) <> '-' then do

                            addToStem = 0

                         end

                      end

                   end

                   if addToStem then do

                      stem[0] = stem[0] + 1

                      stem[stem[0]] = filedate.left(24)' 'filesize.right(14)' 'attrib' 'files[i].toString()

                   end

                end

             end

          end

          if isDirectory & Recursive then do

             if files[i].getAbsolutePath == files[i].getCanonicalPath then do    -- don't descend into symlinks

                stem = FileTree(stem, Rexx files[i], regex, Recursive, FileAndOrDir, format, FilenameOnly, tattrib)

             end

          end

       End

    end

    return stem


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: question about the sysfiletree in sysfile utils.

measel

Type casting is just telling the compiler what “type” of component (variable, object, or object reference) that you are passing. 

 

NetRexx likes components of “type” NetRexx, but will happily use other types.  Just define the component in your class.

 

So if I want a “type” of printstream for a component being passed, I have something like this:

 

method justGet(… p = java.io.printStream, retcount = Rexx)

 

 

The reference to stem[0] is that often it is convenient to keep the number of elements in a dynamic array in 0. 

 

Stem[1] = fn1

Stem[2] = fn2

Stem[3] = fn7

 

Stem[0] = 3

 

Your code seems to use “stem” as a string and an array -  stem1 but also stem[1] – could it be more confusing ?

 

What’re you converting this from ?

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC)
Sent: Wednesday, June 12, 2013 6:26 AM
To: IBM Netrexx
Subject: [Ibm-netrexx] question about the sysfiletree in sysfile utils.

 

I copied the code for SysFileTree and FileTree into a new file that I want to work to just find a file and return the name to me.

I guess I just don’t understand “type casting” and passing values back and forth to called methods.

In this code it looks like the stem is returned from FileTree to SysFileTree and then SysFileTree returns it again. And even though I trace it in detail I can’t figure out what is really getting returned. Should I try to use these system utilities as is and just call them from the jar file?

 

And how can this possibly work:???

 

stem[stem[0]] = files[i].toString()

 

Any tips or education appreciated.

 

/**

* Searches a directory for files

*

* @param spec     file search specification

* @param stem     stem with found results (date, time, size, attributes and file specification)

attributes ADHRS Archive Directory Hidden Readonly System,  . not applicable (A and S), + set, - not set

* @param options       combination of F (files only) D (directories only) B (both, default) S (recursive search)

*                                                          T (time format YY/MM/DD/HH/MM) L (time format YYYY-MM-DD HH:MM:SS) I (search case-insensitive) O (fully qualified file name only)

* @param tattrib  target attribute mask ADHRS (* any state, + set, - not set)

* @param nattrib  NOT IMPLEMENTED new attribute mask to set for found files ADHRS (* unchanged, + set, - not set)

* @return         stem

*                                 

* Note : target attributes are verified by IsDirectory, isHidden, canWrite java calls, not by the actual 'attributes', archive and system attributes are not checked

*/

import java.text

import java.util.concurrent

class SysFileTree

            Properties static public

                        Debug_Level = 50

                        spec1 = string

--                      stem1 = string

                        options1 = string

                        tattrib1 = string

                        nattrib1 = string

            trace methods

method main(arg=String[]) static public        

            if Debug_Level > 10 then trace results

            if Debug_Level > 10 then trace var spec1 stem1 options1 tattrib1 nattrib1 d f

            if arg.length = 0 then do

                say '# Please specify file name and directory'

                exit 1

            end

--          parse arg spec1 "," stem1 "," options1 "," tattrib1 "," nattrib1

            argIn = arg[0]

            loop letterNum = 1 by 1 to arg.length - 1

                        argIn = argIn || arg[letterNum]

            end

            say "arg = argIn ==>" argIn

            parse argIn spec1 "," stem1 "," options1 "," tattrib1 "," nattrib1

            say  "spec1 stem1 options1 tattrib1 nattrib1"

            say   spec1 stem1 options1 tattrib1 nattrib1

            say "stem" SysFileTree(spec1, stem1, options1, tattrib1, nattrib1)

--          say stem1.toString()

 

            return

method SysFileTree(spec, stem, options = 'BL', tattrib = '*****', nattrib = '*****')

            if Debug_Level > 10 then trace results

            if Debug_Level > 20 then trace var d f spec1 stem options1 tattrib1 nattrib

    stem = ''

    stem[0] = 0

    do

       d = spec.substr(1, spec.lastpos('/'))

       f = spec.substr(spec.lastpos('/') + 1)

       regex = f

 

       escapechar = char[] "<a href="file:///\\&#43;()%5e$.%7b%7d[]|">\\+()^$.{}[]|"

       Loop i = 0 to escapechar.length - 1

          pos = regex.pos(escapechar[i], 1)

          Loop while pos > 0

             regex = regex.insert('\\', pos - 1)

             pos = regex.pos(escapechar[i], pos + 2)

          End

       End

       pos = regex.pos('*', 1)

       Loop while pos > 0

          regex = regex.insert('.', pos - 1)

          pos = regex.pos('*', pos + 2)

       End

       regex = regex.translate('.', '?')

 

       Recursive = 0

       if options.upper.pos('S') > 0 then do

          Recursive = 1

       end

 

       if options.upper.pos('I') > 0 then do

          regex = regex.insert('(?i)')

       end

 

       FileAndOrDir = 'B'

       if options.upper.pos('F') > 0 then do

          FileAndOrDir = 'F'

       end

       if options.upper.pos('D') > 0 then do

          FileAndOrDir = 'D'

       end

 

       if options.upper.pos('T') > 0 then do

          format = SimpleDateFormat("yy/MM/dd/HH/mm")

       end

       else do

          if options.upper.pos('L') > 0 then do

             format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")

          end

          else do

             format = SimpleDateFormat()

          end

       end

 

       FilenameOnly = 0

       if options.upper.pos('O') > 0 then do

          FilenameOnly = 1

       end

 

       stem = FileTree(stem, d, regex, Recursive, FileAndOrDir, format, FilenameOnly, tattrib)

    catch IOException

       stem = ''

       stem[0] = 0

    end

    return this

/**

* Private recursively searches a directory for files

*

* @param stem          stem to fill

* @param dirname       directory to start from

* @param regex         regular expression of file to loop for

* @param Recursive     descend recursively into directories

* @param FileAndOrDir  FDB, File Directory or Both

* @param format        SimpleDateFormat

* @param FileNameOnly  format of returned stem, filename only or datetime size .HDR. filename

* @param tattrib       target attributes mask to match .DHR. (* any state, + set, - not set, . not applicable)

* @return         stem

*

*/

  method FileTree(stem, dirname, regex, Recursive, FileAndOrDir, format = SimpleDateFormat, FilenameOnly, tattrib) private signals IOException

    If Debug_Level > 40 then trace results

    If Debug_Level > 40 then trace var stem dirname regex Recursive FileAndOrDir format FilenameOnly tattrib

    dir = File(dirname)

 

    files = File[] dir.listFiles()

    if files <> null then do

       Loop i = 0 to files.length - 1

          f = Rexx files[i].toString()

          say "f" f

          f = f.substr(f.lastpos('/') + 1)

          say "f" f

          isDirectory = files[i].isDirectory()

          say "f.toString()" f.toString()

          if f.toString().matches(regex)  then do

             addToStem = 0

             if FileAndOrDir == 'B' then do

                addToStem = 1

             end

             if FileAndOrDir == 'F' then do

                if \ isDirectory then do

                   addToStem = 1

                end

             end

             if FileAndOrDir == 'D' then do

                if isDirectory then do

                   addToStem = 1

                end

             end

             if addToStem then do

                if FileNameOnly then do

                   stem[0] = stem[0] + 1

                   stem[stem[0]] = files[i].toString()

                end

                else do

                   epoch = files[i].lastModified()

                   cal = Calendar.getInstance()

                   cal.setTimeInMillis(epoch)

 

                   filedate = Rexx format.format(cal.gettime())

                   if isDirectory then do

                      filesize = '0'

                   end

                   else do

                      filesize = Rexx files[i].length()

                   end

 

                   attrib = '.'

                   if isDirectory then do

                      attrib = attrib'D'

                   end

                   else do

                      attrib = attrib'-'

                   end

                   if files[i].isHidden() then do

                      attrib = attrib'H'

                   end

                   else do

                      attrib = attrib'-'

                   end

                   if files[i].canWrite() then do

                      attrib = attrib'-'

                   end

                   else do

                      attrib = attrib'R'

                   end

                   attrib = attrib'.'

                   if tattrib <> '*****' then do

                      if tattrib.substr(2, 1) == '+' & attrib.substr(2, 1) <> 'D' then do

                         addToStem = 0

                      end

                      else do

                         if tattrib.substr(2, 1) == '-' & attrib.substr(2, 1) <> '-' then do

                            addToStem = 0

                         end

                      end

                      if tattrib.substr(3, 1) == '+' & attrib.substr(3, 1) <> 'H' then do

                         addToStem = 0

                      end

                      else do

                         if tattrib.substr(3, 1) == '-' & attrib.substr(3, 1) <> '-' then do

                            addToStem = 0

                         end

                      end

                      if tattrib.substr(4, 1) == '+' & attrib.substr(4, 1) <> 'R' then do

                         addToStem = 0

                      end

                      else do

                         if tattrib.substr(4, 1) == '-' & attrib.substr(4, 1) <> '-' then do

                            addToStem = 0

                         end

                      end

                   end

                   if addToStem then do

                      stem[0] = stem[0] + 1

                      stem[stem[0]] = filedate.left(24)' 'filesize.right(14)' 'attrib' 'files[i].toString()

                   end

                end

             end

          end

          if isDirectory & Recursive then do

             if files[i].getAbsolutePath == files[i].getCanonicalPath then do    -- don't descend into symlinks

                stem = FileTree(stem, Rexx files[i], regex, Recursive, FileAndOrDir, format, FilenameOnly, tattrib)

             end

          end

       End

    end

    return stem


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: question about the sysfiletree in sysfile utils.

Marc Remes-2
In reply to this post by kenner
Kenneth,

the stem is indeed returned from the method call
You should assign it as in

stem = sys.SysFileTree('/home/*nrx', stem, 'S')
Loop i = 1 to stem[0]
   say stem[i]
End


You should know that in classic Rexx, stem.0 - by convention - held the number of items in the stem.
Thus, the code snippet

    stem[0] = stem[0] + 1
    stem[stem[0]] = files[i].toString()

first increases the stem 'count' on stem[0], and then sets the last (new) element of the stem to the 'String'ified
filename at index i in stem files.


--

Marc

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: question about the sysfiletree in sysfile utils.

kenner
The original code was from the "Sysutils" examples that came with the latest release, 3.02c, or I found somewhere. They were in a zip file.

I see now how the number of entries in the array is getting stored in [0] just like was done in REXX. But when this array is returned to the main method, is does not behave like an array.

-- snip --
            argIn = arg[0]
            loop letterNum = 1 by 1 to arg.length - 1
                        argIn = argIn || arg[letterNum]
            end
            say "arg = argIn ==>" argIn
            parse argIn spec1 "," stem "," options1 "," tattrib1 "," nattrib1
            say  "spec1 stem options1 tattrib1 nattrib1"
            say   spec1 stem options1 tattrib1 nattrib1
-- stem[]=SysFileTree(spec1, stem, options1, tattrib1, nattrib1)
        stem = rexx SysFileTree(spec1, stem, options1, tattrib1, nattrib1)
        Loop i = 1 to stem[0]
                say "i" i stem[i]
        End
method SysFileTree(spec, stem, options = 'BL', tattrib = '*****', nattrib = '*****')
        if Debug_Level > 10 then trace results
        if Debug_Level > 20 then trace var d f spec1 stem options1 tattrib1 nattrib
    stem = ''
    stem[0] = 0
    do
       d = spec.substr(1, spec.lastpos('/'))
       f =

-- snip --

Standard output from the top:

arg = argIn ==> /sys/devices/w1_bus_master1/28_*,somestem,BIS,+++++,+++++
spec1 stem options1 tattrib1 nattrib1
/sys/devices/w1_bus_master1/28_* somestem BIS +++++ +++++
f \sys\devices\w1_bus_master1\28-serial_number
f \sys\devices\w1_bus_master1\28-serial_number
f.toString() \sys\devices\w1_bus_master1\28-serial_number
f \sys\devices\w1_bus_master1\28-serial_number\w1_slave
f \sys\devices\w1_bus_master1\28-serial_number\w1_slave
f.toString() \sys\devices\w1_bus_master1\28-serial_number\w1_slave
i 1 SysFileTree@1bbd7b2
i 2 SysFileTree@1bbd7b2
i 3 SysFileTree@1bbd7b2
i 4 SysFileTree@1bbd7b2
i 5 SysFileTree@1bbd7b2


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Marc Remes
Sent: Wednesday, June 12, 2013 10:06 AM
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] question about the sysfiletree in sysfile utils.

Kenneth,

the stem is indeed returned from the method call You should assign it as in

stem = sys.SysFileTree('/home/*nrx', stem, 'S') Loop i = 1 to stem[0]
   say stem[i]
End


You should know that in classic Rexx, stem.0 - by convention - held the number of items in the stem.
Thus, the code snippet

    stem[0] = stem[0] + 1
    stem[stem[0]] = files[i].toString()

first increases the stem 'count' on stem[0], and then sets the last (new) element of the stem to the 'String'ified filename at index i in stem files.


--

Marc

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: question about the sysfiletree in sysfile utils.

Marc Remes-2
Page 76 of NLR 3.01 says

A variable of type Rexx must have been assigned a value before indexing is used on it.

BTW, I have not found a way to pass a stem 'by reference', hence the need to return the associative array.
The recipient does need to have a value assigned to act as indexed string.

--

Marc

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: question about the sysfiletree in sysfile utils.

measel
In reply to this post by kenner
Use "loop over" to process sequentially :

Loop myindex over stem
    Say stem[myindex]
end

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC)
Sent: Wednesday, June 12, 2013 12:26 PM
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] question about the sysfiletree in sysfile utils.

The original code was from the "Sysutils" examples that came with the latest release, 3.02c, or I found somewhere. They were in a zip file.

I see now how the number of entries in the array is getting stored in [0] just like was done in REXX. But when this array is returned to the main method, is does not behave like an array.

-- snip --
            argIn = arg[0]
            loop letterNum = 1 by 1 to arg.length - 1
                        argIn = argIn || arg[letterNum]
            end
            say "arg = argIn ==>" argIn
            parse argIn spec1 "," stem "," options1 "," tattrib1 "," nattrib1
            say  "spec1 stem options1 tattrib1 nattrib1"
            say   spec1 stem options1 tattrib1 nattrib1
-- stem[]=SysFileTree(spec1, stem, options1, tattrib1, nattrib1)
        stem = rexx SysFileTree(spec1, stem, options1, tattrib1, nattrib1)
        Loop i = 1 to stem[0]
                say "i" i stem[i]
        End
method SysFileTree(spec, stem, options = 'BL', tattrib = '*****', nattrib = '*****')
        if Debug_Level > 10 then trace results
        if Debug_Level > 20 then trace var d f spec1 stem options1 tattrib1 nattrib
    stem = ''
    stem[0] = 0
    do
       d = spec.substr(1, spec.lastpos('/'))
       f =

-- snip --

Standard output from the top:

arg = argIn ==> /sys/devices/w1_bus_master1/28_*,somestem,BIS,+++++,+++++
spec1 stem options1 tattrib1 nattrib1
/sys/devices/w1_bus_master1/28_* somestem BIS +++++ +++++ f \sys\devices\w1_bus_master1\28-serial_number
f \sys\devices\w1_bus_master1\28-serial_number
f.toString() \sys\devices\w1_bus_master1\28-serial_number
f \sys\devices\w1_bus_master1\28-serial_number\w1_slave
f \sys\devices\w1_bus_master1\28-serial_number\w1_slave
f.toString() \sys\devices\w1_bus_master1\28-serial_number\w1_slave
i 1 SysFileTree@1bbd7b2
i 2 SysFileTree@1bbd7b2
i 3 SysFileTree@1bbd7b2
i 4 SysFileTree@1bbd7b2
i 5 SysFileTree@1bbd7b2


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Marc Remes
Sent: Wednesday, June 12, 2013 10:06 AM
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] question about the sysfiletree in sysfile utils.

Kenneth,

the stem is indeed returned from the method call You should assign it as in

stem = sys.SysFileTree('/home/*nrx', stem, 'S') Loop i = 1 to stem[0]
   say stem[i]
End


You should know that in classic Rexx, stem.0 - by convention - held the number of items in the stem.
Thus, the code snippet

    stem[0] = stem[0] + 1
    stem[stem[0]] = files[i].toString()

first increases the stem 'count' on stem[0], and then sets the last (new) element of the stem to the 'String'ified filename at index i in stem files.


--

Marc

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: question about the sysfiletree in sysfile utils.

Marc Remes-2
Kenneth,

looking again at your code, I think I see what's wrong.

You called your class SysFileTree, and when calling the SysFileTree method you are actually calling the constructor.
Constructors return a value of the type defined by that class (sometimes known as an instance of that
class).
The cast of stem = Rexx SysFileTree(spec1, stem, options1, tattrib1, nattrib1) ringed a bell.
Even when you cast the object to a Rexx object, it does not make it a stem.

You need to instantiate a sysutils object - either from the jar or inline, and call the method on the object.
       

import java.text

import java.util.concurrent

class MainClass
...

         sys = sysutils()

-- stem[]=SysFileTree(spec1, stem, options1, tattrib1, nattrib1)
        stem = sys.SysFileTree(spec1, stem, options1, tattrib1, nattrib1)
        Loop i = 1 to stem[0]
                say "i" i stem[i]
        End


class sysutils

   method SysFileTree(spec, stem, options = 'BL', tattrib = '*****', nattrib = '*****')
     stem = ''
     stem[0] = 0
     do
...

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: question about the sysfiletree in sysfile utils.

kenner
Yeah, that's where I'm heading with this. I need to understand the instantiation of an object of the class type. I follow you right up to the last line. "Call the method on the object" totally befuddles me.  An example would help.

If Marc Remes is still on this list, could you shed some light on how the sysutils() package was meant to be used? Should I put it in a jar file and add it to my classpath? Great stuff, just what I need to get my BBB to heat my hot liquor tank.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Marc Remes
Sent: Wednesday, June 12, 2013 3:56 PM
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] question about the sysfiletree in sysfile utils.

Kenneth,

looking again at your code, I think I see what's wrong.

You called your class SysFileTree, and when calling the SysFileTree method you are actually calling the constructor.
Constructors return a value of the type defined by that class (sometimes known as an instance of that class).
The cast of stem = Rexx SysFileTree(spec1, stem, options1, tattrib1, nattrib1) ringed a bell.
Even when you cast the object to a Rexx object, it does not make it a stem.

You need to instantiate a sysutils object - either from the jar or inline, and call the method on the object.
       

import java.text

import java.util.concurrent

class MainClass
...

         sys = sysutils()

-- stem[]=SysFileTree(spec1, stem, options1, tattrib1, nattrib1)
        stem = sys.SysFileTree(spec1, stem, options1, tattrib1, nattrib1)
        Loop i = 1 to stem[0]
                say "i" i stem[i]
        End


class sysutils

   method SysFileTree(spec, stem, options = 'BL', tattrib = '*****', nattrib = '*****')
     stem = ''
     stem[0] = 0
     do
...

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: question about the sysfiletree in sysfile utils.

measel
Kenneth, objects and instantiation are like plans and building things.

A class definition -->>  I have plans for a boat.   Boat.class

When I build a new boat -->>  A new "instance" of the boat class.  

That boat runs on the thread I am in, unless I create a new thread where I can run the boat.

The boat has methods to control it, and properties about it.  

Consider:    ( cod is for example and not meant to be syntactically correct  )

Class boat
     Properties
        color = "white"
        rudder = 0

    Method turn ( direction = Rexx )
            Select
        When direction = 'left' then  rudder = rudder + 1
        When direction = 'right' then rudder = rudder - 1
        Otherwise
                Say 'I need a direction'
               End

     Method startMotor( )

Main ()
     myBoat = boat     /* a new instance of class boat */
    myBoat.color = "blue"       /* set the properties of this instance of boat */
   
    myBoat.startMotor()
    myBoat.turn('left')

end

/* ----------------------------------------------- */
If we wanted a boat factory we would change the start method to launch each boat on a new thread.

If you want, you can use my boat plans to build a new boat with more controls or features:

Class Catalina extends Boat implements (turn, startMotor)
     Properties
           power-type = "diesel"

    Method motor_speed ( knots = Integer )
         
...

That help any ?

 



-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC)
Sent: Thursday, June 13, 2013 6:52 AM
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] question about the sysfiletree in sysfile utils.

Yeah, that's where I'm heading with this. I need to understand the instantiation of an object of the class type. I follow you right up to the last line. "Call the method on the object" totally befuddles me.  An example would help.

If Marc Remes is still on this list, could you shed some light on how the sysutils() package was meant to be used? Should I put it in a jar file and add it to my classpath? Great stuff, just what I need to get my BBB to heat my hot liquor tank.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Marc Remes
Sent: Wednesday, June 12, 2013 3:56 PM
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] question about the sysfiletree in sysfile utils.

Kenneth,

looking again at your code, I think I see what's wrong.

You called your class SysFileTree, and when calling the SysFileTree method you are actually calling the constructor.
Constructors return a value of the type defined by that class (sometimes known as an instance of that class).
The cast of stem = Rexx SysFileTree(spec1, stem, options1, tattrib1, nattrib1) ringed a bell.
Even when you cast the object to a Rexx object, it does not make it a stem.

You need to instantiate a sysutils object - either from the jar or inline, and call the method on the object.
       

import java.text

import java.util.concurrent

class MainClass
...

         sys = sysutils()

-- stem[]=SysFileTree(spec1, stem, options1, tattrib1, nattrib1)
        stem = sys.SysFileTree(spec1, stem, options1, tattrib1, nattrib1)
        Loop i = 1 to stem[0]
                say "i" i stem[i]
        End


class sysutils

   method SysFileTree(spec, stem, options = 'BL', tattrib = '*****', nattrib = '*****')
     stem = ''
     stem[0] = 0
     do
...

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: question about the sysfiletree in sysfile utils.

Marc Remes-2
In reply to this post by kenner
On 06/13/2013 01:51 PM, Kenneth Klein (TEMA TPC) wrote:
> Yeah, that's where I'm heading with this. I need to understand the instantiation of an object of the class type. I follow you right up to the last line. "Call the method on the object" totally befuddles me.  An example would help.
>
> If Marc Remes is still on this list, could you shed some light on how the sysutils() package was meant to be used? Should I put it in a jar file and add it to my classpath? Great stuff, just what I need to get my BBB to heat my hot liquor tank.
>

It's me Kenneth ;

The zip file you found on http://netrexx.org/tools.nsp has some sample usage examples.
It's up to you how to access it, either from the generated class file or from a jar, it's just the same for netrexx or
java. The class file just needs to be found on the classpath.

FYI,
instantiation (or object creation) :

    sys = sysutils()

call the method :

    stem = sys.SysFileTree('/home/*nrx', stem, 'S')

loop over the stem :

    Loop i = 1 to stem[0]
       say stem[i]
    End




--

Marc

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: question about the sysfiletree in sysfile utils.

kenner
In reply to this post by measel
Thanks loads, Marc and Mike. Your help has gotten my program to the point where it is reading and writing and finding files in unknown subdirectories. When the BBB can read a temp probe and turn on/off a heater I will post the code.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Measel, Mike
Sent: Thursday, June 13, 2013 9:51 AM
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] question about the sysfiletree in sysfile utils.

Kenneth, objects and instantiation are like plans and building things.

A class definition -->>  I have plans for a boat.   Boat.class

When I build a new boat -->>  A new "instance" of the boat class.  

That boat runs on the thread I am in, unless I create a new thread where I can run the boat.

The boat has methods to control it, and properties about it.  

Consider:    ( cod is for example and not meant to be syntactically correct  )

Class boat
     Properties
        color = "white"
        rudder = 0

    Method turn ( direction = Rexx )
            Select
        When direction = 'left' then  rudder = rudder + 1
        When direction = 'right' then rudder = rudder - 1
        Otherwise
                Say 'I need a direction'
               End

     Method startMotor( )

Main ()
     myBoat = boat     /* a new instance of class boat */
    myBoat.color = "blue"       /* set the properties of this instance of boat */
   
    myBoat.startMotor()
    myBoat.turn('left')

end

/* ----------------------------------------------- */ If we wanted a boat factory we would change the start method to launch each boat on a new thread.

If you want, you can use my boat plans to build a new boat with more controls or features:

Class Catalina extends Boat implements (turn, startMotor)
     Properties
           power-type = "diesel"

    Method motor_speed ( knots = Integer )
         
...

That help any ?

 



-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC)
Sent: Thursday, June 13, 2013 6:52 AM
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] question about the sysfiletree in sysfile utils.

Yeah, that's where I'm heading with this. I need to understand the instantiation of an object of the class type. I follow you right up to the last line. "Call the method on the object" totally befuddles me.  An example would help.

If Marc Remes is still on this list, could you shed some light on how the sysutils() package was meant to be used? Should I put it in a jar file and add it to my classpath? Great stuff, just what I need to get my BBB to heat my hot liquor tank.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Marc Remes
Sent: Wednesday, June 12, 2013 3:56 PM
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] question about the sysfiletree in sysfile utils.

Kenneth,

looking again at your code, I think I see what's wrong.

You called your class SysFileTree, and when calling the SysFileTree method you are actually calling the constructor.
Constructors return a value of the type defined by that class (sometimes known as an instance of that class).
The cast of stem = Rexx SysFileTree(spec1, stem, options1, tattrib1, nattrib1) ringed a bell.
Even when you cast the object to a Rexx object, it does not make it a stem.

You need to instantiate a sysutils object - either from the jar or inline, and call the method on the object.
       

import java.text

import java.util.concurrent

class MainClass
...

         sys = sysutils()

-- stem[]=SysFileTree(spec1, stem, options1, tattrib1, nattrib1)
        stem = sys.SysFileTree(spec1, stem, options1, tattrib1, nattrib1)
        Loop i = 1 to stem[0]
                say "i" i stem[i]
        End


class sysutils

   method SysFileTree(spec, stem, options = 'BL', tattrib = '*****', nattrib = '*****')
     stem = ''
     stem[0] = 0
     do
...

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/