using replace one in tricky way

Author: (lalitpct)

In a variable below is the content and I want to remove the path shown for a file , and I would like to do in uniface

***00-RETURN: Listing Files:
-rwxrwxr-x    1 smt2uxb  smt2uxb       28561 May 12 2010  /opt/uat/eur/sources/sqr/ftp_make.sqr:1
-rwxrwxr-x    1 smt2uxb  smt2uxb       28560 May 13 2010  /opt/uat/eur/sources/sqr/ftp_make.sqr

what I was thinking was
1)find first position " /" via scan command
2)Find end of the word found from above position
3)from the end to the left find /
4)Replace the above string from first " /" to the end "/" in the variable
5)loop until all of them are replaced

the second step I am unable to think of anyway to do it , please let me know if any one has got any idea to do  or if they have done this before.
If you have better idea on this you can tell me that as well


  1. Hi, maybe something like this can help you,

    while (vsexit="N")

    Regards, Rafa.

    Author: uniface8 (
  2. Hi

    Thanks for reply it seems $replace is a better way of achieveing my goal , thanks for pointing to that

    however it gives output as 

    -rwxrwxr-x    1 smt2uxb  smt2uxb       28561 May 12 2010   uat a c c c/ftp_make.sqr:1

     $syntax("/&*/")   how does it work ? I mean if  we can trac patter like /opt/uat/eur/a/b/c/c/c/c/c/  ( /*/) then it will be done in one single command  

    text_to_view="-rwxrwxr-x    1 smt2uxb  smt2uxb       28561 May 12 2010  /opt/uat/eur/a/b/c/c/c/c/c/ftp_make.sqr:1"
    text_to_view=$replace(text_to_view,1,$syntax("/&*/")," ", -1)

    Author: lalitpct (
  3. That pattern finds /any character/ , if you do
    $replace(text_to_view,1,$syntax("/&*/")," ", -1)

    you replace /opt/   uat  /eur/  a   /b/   c   /c/   c   /c/   c/ --> uat a c c c/ftp_make.sqr

    look at the example;
    while (..)
        $replace(text_to_view,1,$syntax("/&*/"),"/", -1)

    at the end of the first loop you get
    /opt/uat/eur/a/b/c/c/c/c/c/ftp_make.sqr -->/uat/a/c/c/c/ftp_make.sqr
    in the second
    the third
    and finally

    Modify the instruction to end the while cause in 8.4 rscan not exist.

    Regards, Rafa.

    Author: uniface8 (
  4. thanks it worked ,

    Author: lalitpct (
  5. always running scan througl a long text results in unacceptable performance.

    So at first separate the file so you work always with a single line.

    if you use the current uniface version, there is a "scan from right side" $rscan to speed up processing.

    Using an external file gives you the alternative to apply regular-expression replacement (outside of uniface)
    and just load the resulting file.


    P.S: If it is an external file you can use USEQREAD to read it line-by-line with lightspeed processing.
    AND you reduce memory consumption from "the whole filesize" down to "the longest line"

    Author: ulrich-merkel (
  6. uniface version is 8.4 and hence it seems rscan is not working

    Author: lalitpct (
  7. ... and 8.4 is NOT the current version I mentioned

    Author: ulrich-merkel (
  8. From my personal archives: a "rightscan avant la lettre", which will work in Uniface version 8 and below:


    entry RIGHTSCAN
       string  pi_string   : IN
       string  pi_profile  : IN
       numeric po_position : OUT
       numeric lv_len_profile
       string  lv_characters

    length pi_profile
    lv_len_profile = $result

    length pi_string
    po_position   = $result - lv_len_profile + 1
    lv_characters = pi_string[po_position:lv_len_profile]
    while(lv_characters != pi_profile & po_position > 0)
       po_position   = po_position - 1
       lv_characters = pi_string[po_position:lv_len_profile]

    Usage example:
    call RIGHTSCAN(u_glab.ucrelsh, "_", lv_positie)

    Author: Arjen van Vliet (

  9. uniface version is 8.4 and hence it seems rscan is not working

    So it would have been better if you posted this in the Uniface 8 part of the forum...

    Author: Theo Neeskens (
  10. i have moved it to 8.4

    Author: lalitpct (
  11. because uniface is terrible slow handling longer texts and does not provide enough string manipulation routines I recommend external processing.

    Using GAWK.EXE (open source awk for windows) a simple command line (use a SPAWN or activate OSCOMMAND) will do the job:

    C:\#mig_awk>gawk " {sub(/\/.*\//,'',$0);print}" <
    ***00-RETURN: Listing Files:
    -rwxrwxr-x    1 smt2uxb  smt2uxb       28561 May 12 2010  ftp_make.sqr:1
    -rwxrwxr-x    1 smt2uxb  smt2uxb       28560 May 13 2010  ftp_make.sqr

    it's fast, straight foreward so why spend time and energy in doing it otherwise.

    And if you got the info from a unix system, why not ask if someone can "pipe" this awk command into the preparation sequence ?


    Author: ulrich-merkel (
  12. Hello


    i dont remember in what version uniface introduce the $itemcount , $itemnr but if these commands are available to your version you can simply translate your string in list and get the last element from list

    vsFileName = "-rwxrwxr-x    1 smt2uxb  smt2uxb       28560 May 13 2010  /opt/uat/eur/sources/sqr/ftp_make.sqr"

    ;The ; is the golden ;
    vsFullPath = $ItemNr($ItemCount($Replace(vsFullPath,1,"/","·;",-1)),$Replace(vsFullPath,1,"/","·;",-1))

    ;Result Is :
    ; vsFullPath = "ftp_make.sqr"

    Author: jtsagara (
  13. Without $itemcount it is possibile to use

    vsFullPath = $ItemNr(-1,$Replace(vsFullPath,1,"/","·;",-1))

    to extract the last element from the list.


    Author: Marco (
  14. Yes marco


    this is possible after some patching ( if i remember well ) in uniface

    cause in first edititions of uniface that can handle $itemnr ( i think ~ 8 or 9 ) had a bug with -1




    Author: jtsagara (