Uniface User Forum

 View Only
  • 1.  String Extraction issue on very large text files

    Posted 11-02-2020 10:03

    Hi Unifacers,

    I've just found a very specific issue I would like to share to know if anyone has already met something similar.

    In a VERY OLD piece of code a Uniface application was splitting a string content in 2 parts:

    fileload v_inputfile, v_content
    scan v_content, "%%^"
    v_fin = $result
    if (v_fin <= 0) return(-1)
    v_ini = v_fin + 1
    v_fin = v_fin - 1
    v_firstrow = v_content[1:v_fin]
    v_content = v_content[v_ini]

    For business reason input files dimension at customer site is growth a lot during last year and this piece of code was is some situation NOT anymore working correctly, truncating v_content to about 128-129MB. I have found a workaround forcing string extraction up to length of v_content:

    fileload v_inputfile, v_content
    scan v_content,"%%^"
    v_fin = $result
    if (v_fin <= 0) return(-1)
    v_ini = v_fin + 1
    v_fin = v_fin - 1
    v_firstrow = v_content[1:v_fin]
    v_fin = $length(v_content)
    v_content = v_content[v_ini, v_fin]

    Has anyone met this situation already?

    Environment:
    Platform: Windows10 2004 64bit
    Uniface: 9.7.05.054 32bit

    Regards,
    Gianni



  • 2.  RE: String Extraction issue on very large text files

    Posted 11-02-2020 10:28

    Hi Gianni

    Just an idea to solve it, not proofed yet 🙂

    v_content = $replace(v_content,1,"%%^","°;",-1)   ;  Where °; is GOLD-;
    v_firstrow = $itemnr(1,v_CONTENT)
    delitem v_CONTENT.1

    Ingo




  • 3.  RE: String Extraction issue on very large text files
    Best Answer

    ROCKETEER
    Posted 11-02-2020 11:11

    Hi Gianni,

    $split might be quicker in this case:

    v_fin = $split(v_content,1,"%%^",v_firstrow,v_content)

    Daniel



  • 4.  RE: String Extraction issue on very large text files

    Posted 11-05-2020 06:25

    Hi Ingo and Daniel,

    thanks for your answers. I made some stress test on the specific context and both your solutions were working; I've choosen to improve the piece of code using the one from Daniel because it is more simple.
    Stability of hosting application became greater.

    Best Regards,
    Gianni



  • 5.  RE: String Extraction issue on very large text files

    Posted 11-05-2020 13:10

    Hi Gianni

    My idea was to get all lines from content 🙂

    v_content = $replace(v_content,1,"%%^","°;",-1) FORLIST v_line in v_content  call LP_DO_SOMETHING(v_line)ENDFOR


  • 6.  RE: String Extraction issue on very large text files

    Posted 11-05-2020 13:22

    Yes, I've got that from your few lines...but my actual need was the simpler one.

    Anyhow, a BIG thank you!
    It is always nice to have a small issue, discovering someone immediately answering to it! 🙂 🙂 🙂

    Best Regards,
    Gianni