OS2World OLD-STATIC-BACKUP Forum

OS/2 - General => Marketplace => Topic started by: NNYITGuy on 2008.10.23, 16:17:36

Title: **This is a FOR HIRE applet build request...
Post by: NNYITGuy on 2008.10.23, 16:17:36
Hello,

I need a simple CLI applet for reading and copying info from TXT based log files.  The app needs to find the EOF and then look backwards one char at a time until a matched set of chars is found.  The app will then copy from that point to EOF to a separate TXT file.  The chars to be searched and identified must be defineable as an external param defined from the CL or from a text based INI file.

If the applet completes this task satisfactorily then other TXT based recognition features will be added for expanded functionality for an additional project.

Please respond to this post if you are interested in this programming task.  Any compiled language will be acceptable, but I would like to support the Sibyl or WDSibyl development platform.  Source code must also be provided as part of the finished applet.

I mentioned CLI above, but a GUI would be accepted for a WDSibyl developed applet.

Thank You and Best Regards,
Todd Simpson
Title: Re: **This is a FOR HIRE applet build request...
Post by: Pete on 2008.10.23, 18:06:31
Hi Todd

Sounds like it could keep me out of trouble for a little while  :-)

I would probably use  WDSibyl as I am (nearly) competent using that package which would mean your choice as regards CLI or GUI - or maybe a version of each.

About the best reference I can give as to my capabilities as a developer is USBcfg, a USB configuration tool for OS/2 based systems. You can download a copy from hobbes to see what you think  http://hobbes.nmsu.edu/pub/os2/system/usbcfgb7a.zip

USBcfg has to read the config.sys file to obtain all existing USB settings which involves a certain amount of "char matching".

If having looked at USBcfg you think may be I could do the job please feel free to email me losepete@ntlworld.com

Regards

Pete
Title: Re: **This is a FOR HIRE applet build request...
Post by: NNYITGuy on 2008.10.24, 23:36:58
Hi Pete,

I will send you off an email shortly...

Thanks,
Todd
Title: Re: **This is a FOR HIRE applet build request...
Post by: zircon on 2008.10.25, 12:10:05
Too bad it must be compiled - in Rexx it would be fairly trivial...


/*REXX script for reading and copying info from TXT based log files.
by Zircon
Version 0.1 
2008-10-25
*/

logfile = "logfile.txt"
writefile = "logfile.out"
inifile = "readfile.ini"


/* the chars to be searched and identified must be defineable as an external param defined from the CL */
parse arg searchstring

/* or from a text based INI file.*/
if searchstring = ""
then searchstring = readinifile( inifile )
if searchstring = "" then call nosearchstring


/* find the EOF */
call stream logfile , "C" , "CLOSE"
data = charin( logfile , 1 , chars( logfile ))
call stream logfile , "C" , "CLOSE"


/* look backwards one char at a time until a matched set of chars is found*/
lp = lastpos( searchstring , data )
if lp = 0 then call search_string_doesnt_exist searchstring
else lp = lp - 1


/* copy from that point to EOF */
parse var data . +(lp) keepdata



/* to a separate TXT file */
call lineout writefile , ""
call lineout writefile , "*******  -- DIVIDER -- *******"
call lineout writefile , ""
call charout writefile , keepdata

exit


/* Read search string from a text based INI file.*/
readinifile: procedure
parse arg readthisfile
searchforstring = ""
if fileexists( readthisfile ) <> 1 then call file_doesnt_exist readthisfile
else
call stream readthisfile , "C" , "CLOSE"
do while lines( readthisfile) > 0
   line = strip( linein( readthisfile ) )
   parse var line label "=" searchforstring
   if translate( label ) = "SEARCHSTRING" then do
   searchforstring = strip( searchforstring )
   leave
   end
   else searchforstring = ""
end
call stream readthisfile , "C" , "CLOSE"
return searchforstring
exit

nosearchstring: procedure expose inifile
say "No search string has been defined"
say "Define search string in " || inifile || " as follows:"
say "SEARCSTRING = [string to look for]"
say ""
say "You can also define the string on the command line as follows"
say "readfile [string to look for]"
say "Exiting..."
exit

search_string_doesnt_exist: procedure
parse arg searchstring
say "No instances of"
say searchstring
say "were found."
say ""
say "Exiting..."
exit

file_doesnt_exist: procedure
parse arg filename
say filename || " doesn't exist."
say "Exiting..."
exit


/***************************************************************************************************
function: Check whether a file, directory or device exists

call:     rc = FileExists( fileToTest )

where:    fileToTest - name of the file to test

returns:  -2 - invalid parameter
           -1 - cannot detect (e.g. the drive is not ready)
            0 - no file, device or directory with this name exists
            1 - the file exists
            2 - a device with this name exists
            3 - a directory with this name exists

***************************************************************************************************/
FILEEXISTS: Procedure                                                      /* v2.90 - from RxTT35 */
Trace Off
Parse Arg filename
Trace Off

/* install temporary error handler                                                                */
Signal On Notready Name Fileexistserror
Signal On Failure Name Fileexistserror
Signal On Error Name Fileexistserror

Thisrc = -2                                                      /* rc = -2 ->> invalid parameter */

/* check the parameter                                                                            */
If strip( filename ) <> "" Then Do
  thisrc = -1                                                        /* rc = -1 ->> cannot detect */

  /* check whether the drive with the file is ready                                               */
  Call stream filename
  /* Lower error detection level to determine whether the name is that of a device (e.g. "LPT1")  */
  Signal Off Notready

  If stream( filename, "c", "QUERY EXISTS" ) <> "" Then Do
    /* seems that the file exists -- check wheter it is a device                                  */
    If stream( filename, "c", "QUERY DATETIME" ) == "" Then
      thisrc = 2                                                      /* rc = 2 ->> a device name */
      Else
        thisrc = 1                                                      /* rc = 1 ->> a file name */
  End
    Else Do
      /* The file apparently does not exist -- check whether a directory with the name exists     */

      /* Save the current directory of the current drive                                          */
      thisdir = directory()
      /* Save the current directory of the drive on which the target should exist                 */
      tempdir = directory( filespec( "Drive", filename ) )

      If directory( filename ) <> "" Then
        thisrc = 3                                      /* rc = 3 ->> a dir with this name exists */
        Else
          thisrc = 0             /* rc = 0 ->> no file, device or directory with this name exists */

      /* restore the current directory of the target drive                                        */
      Call directory tempdir
      /* restore the current directory of the current drive                                       */
      Call directory thisdir
    End
End

FILEEXISTSERROR:
Return thisrc

Title: Re: **This is a FOR HIRE applet build request...
Post by: RobertM on 2008.10.25, 20:28:39
Quote from: zircon on 2008.10.25, 12:10:05
Too bad it must be compiled - in Rexx it would be fairly trivial...


rxCLS to "compile" it maybe?
Title: Re: **This is a FOR HIRE applet build request...
Post by: ModZilla on 2008.11.04, 16:21:05
COULD I [try/use] this code in REXX as is w/o copyright, cut and paste?  thx ZIRCON

mz
Title: Re: **This is a FOR HIRE applet build request...
Post by: RobertM on 2008.11.04, 21:30:19
ModZilla,

If Zircon comes to an agreement with you, and you still need an executable, you can find RxCLS on Hobbes (search for RxCLS, and grab the newest version - dont worry about it being very old).

It will still rely on the REXX subsystem (but then again, every OS/2 machine has one - or chances are, doesnt run), but will then give you an executable.


Also, if you are in need of GUI support, or the app being compiled to some sort of GUI or closer to "real" executable, then you may wish to try to find a copy of VisPro REXX, or Watcom VX-REXX, etc. They can often be found pretty cheap here or on eBay.

Robert
Title: Re: **This is a FOR HIRE applet build request...
Post by: Saijin_Naib on 2008.11.04, 21:39:11
Cant DrDialog be used to make the REXX app into a PM-GUI app? I was toying with DrDialog as I wanted to make a Rally timing app for OS/2. I failed :P
Title: Re: **This is a FOR HIRE applet build request...
Post by: RobertM on 2008.11.04, 22:21:37
Quote from: Saijin_Naib on 2008.11.04, 21:39:11
Cant DrDialog be used to make the REXX app into a PM-GUI app? I was toying with DrDialog as I wanted to make a Rally timing app for OS/2. I failed :P

Indeed it can. So can another app out there who's name eludes me at the moment (think it is on Hobbes though). I've used both, but can't recall whether they make true executables, or REXX wrapped stuff with an EXE stub.

-Robert
Title: Re: **This is a FOR HIRE applet build request...
Post by: RobertM on 2008.11.04, 22:35:40
I must be getting senile in my old age. The other REXX GUI builder is GPF-Rexx. All of them (VX, DrD, GPF, VisPro, etc) support loading standard REXX external function DLLs, and various of the DLLs even have specialized calls (above and beyond the standard REXX ones) for certain of the GUI builders. And of course, each (or most) has additional add-on packages that extend certain aspects of the GUI support (such as fancier slider bars, status bars, different entry field classes, etc).

The only limitations, (GUI-wise) are some seem limited to using the OS/2 Warp 3 style tabbed notebooks (long, left side tabs instead of the top tabs introduced in Warp 4 and later), and most of them do not create "OS/2 aware" objects (ie: ones you can change via dragging and dropping fonts or colors onto from the various palettes).


ModZilla:
If you are interested in any of them, I would check out the OS/2 eZine site, and EDM/2. Both have reviews or tutorials/examples for all of the OS/2 REXX GUI builders, and between both sites, cover the features and limitations pretty thoroughly. One note, you will find (if memory serves) some reviews that compare them side-by-side (but only compare two-three at a time), so you may need to read multiple reviews and do a comparison based off all of the reviews. Inotherwords, there seems to be no single document that compares all of them in the same article.

-Robert
Title: Re: **This is a FOR HIRE applet build request...
Post by: zircon on 2008.11.06, 02:48:36
Quote from: ModZilla on 2008.11.04, 16:21:05
COULD I [try/use] this code in REXX as is w/o copyright, cut and paste?  thx ZIRCON

Go ahead.
Title: Re: **This is a FOR HIRE applet build request...
Post by: ModZilla on 2009.02.17, 16:40:19
THX for the go-ahead, been away for awhile but will try and many thanks also to Robert who so graciously directed me to the OS/2 ezine site...I am not a big REXX fan but I am trying to expand my horizons as I think this work is important, the expansion of OS/2 with the program for the serial port as USB control was a keen move as well...thx all