ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

read text file on IFS from RPG

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • read text file on IFS from RPG

    Okay right click on you desktop..
    select new text document
    goto your favorite website and copy some text

    paste this text into your newly created text
    document....then close give the file an easy name
    like test.txt

    place this file on the ifs

    then call the attached program
    this program will read the IFS file and
    write to a subfile.

    I could see this beign used with Bob Cozzi's
    isocket program or cgidev2 program?? (API)
    to pull down a website.

    then this website can be read from RPG...
    example(s) current gold price....exchange rates...

    anyway here it is let us know what
    you do with it

    jamie
    Attached Files
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

  • #2
    Re: read text file on IFS from RPG

    Nice, thanks.
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: read text file on IFS from RPG

      Just a refresh on this one I downloaded scott's (Scott C. Klement) socket tool(s)
      loaded it in about 5 minutes. found example program 1 EXAMPLE1
      modfied it to pull down a text file from code400.
      which I could process with the above code...

      I guess the next step would be to see if we could pull down the html code
      to a webpage auto magically.
      any takers??

      This code looks simple but the copy books are huge it involves service programs
      and binding directories.

      PHP Code:
      H DFTACTGRP(*NOACTGRP(*NEW) BNDDIR('HTTPAPI')                                   
                                                                                        
       *                                                                                
       * 
      The simplest thing that HTTPAPI can do is download a                           
       
      file from a web server.  This example demonstrates                             
       
      retrieving a PDF document from my web server and saving                        
       
      it to the IFS on your iSeries.                                                 
       *                                                                                
                                                                                        
      D/copy qrpglesrc,httpapi_h                                                        
                                                                                        
      D rc              s             10I 0                                             
      D msg             s             52A                                               
                                                                                        
      C
      Retrieve ==>  http://www.pacificmidrange.org/documents/V5R4i5OS_What_s_New.pdf 
                                                                                        
      c                   eval      rc http_url_get(                                  
      c                             'http://www.code400.com/'+                          
      c                             'downloads/http.txt':                               
      c                             '/jamie/test.txt')                      
                                                                            
      c                   if        rc <> 1                                 
      c                   
      eval      msg http_error                        
      c
      **  'msg' now contains an error message that you can                 
      c
      **  display to the user.                                             
      c                   endif                                             
                                                                            
      c                   eval      *inlr = *on 

      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment


      • #4
        Re: read text file on IFS from RPG

        Looks interesting. How is the reading done from IFS done?

        Read all or page at a time.

        I am thinking about our 100-125 meg EDI files.

        Comment


        • #5
          Re: read text file on IFS from RPG

          It pulls in chunks (in my case 75 Characters at a time) and processes them in a loop until EOF.

          Limited to 75 only so that I can show on display.
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #6
            Re: read text file on IFS from RPG

            This looks interesting....is it saving the pdf as a text file on the ifs? I'm looking for a way to automate the process of taking pdfs [for now, from a windows folder] and saving them as text files on our ifs. - John

            Comment


            • #7
              Re: read text file on IFS from RPG

              Might not be that easy....PDF is full of formatting "codes" that you would have to parse......you may be able to use a freeware conversion tool to do the conversion once you get it down on your box...

              give it a try and let us know what you find.

              jamie
              All my answers were extracted from the "Big Dummy's Guide to the As400"
              and I take no responsibility for any of them.

              www.code400.com

              Comment


              • #8
                Re: read text file on IFS from RPG

                Ok, found a pdf extract shell at pdf.tools.com and tried the evaluation version...has command line run capability...so it can be used to automate the conversion of pdfs to text! Awesome! - John

                Comment


                • #9
                  Re: read filenames from IFS directory??

                  Anyone have an API way to do this...it'll be better than reading a spool file created from the dsplnk cmd. Thanks! - John

                  Comment

                  Working...
                  X