Topic
  • 3 replies
  • Latest Post - ‏2014-07-28T20:53:10Z by llandale
etleg
etleg
12 Posts

Pinned topic Diff is not working for long strings?

‏2014-07-28T09:09:33Z |

Hallo

I have a following behavior/question:

I wrote a script (layout) and it work almost properly.

pragma encoding, "UTF-8"
XFLAGS_ &=~AutoDeclare_;
pragma runLim,    0




Buffer oldVal = create;
Buffer newVal = create;
Buffer result = create;

oldVal = obj."old_TEXT";
newVal = obj."new_TEXT";


diff(result,oldVal, newVal,false)

displayRichWithColor stringOf ( result)

delete(newVal)
delete(oldVal)
delete(result)

In 99% off all rows it worked as expected.

But they are some rows where the script shows nothing. The output is empty.

My suggestion is that if buffer of oldVal or newVal is to long then the function "diff" is not working.

 

So is it possible to make it work??? Or is there a workaround?? Or is there an error in my script?

p

Thank You

 

German

  • SudarshanRao
    SudarshanRao
    54 Posts
    ACCEPTED ANSWER

    Re: Diff is not working for long strings?

    ‏2014-07-28T12:08:29Z  

    There is an upper limit on the size of buffers that can be compared.
    There was a defect logged recently (PI12272), to increase this upper limit. The defect is fixed in v9.6, where the limit was increased. So, your code might work better on v9.6, depending on the size of text that is being compared.

    As per the definition of diff perm:
    The result is valid only when a non-null string is returned.

    So, if the result buffer is null, you could handle that. And, I think it also returns an error when the perm fails.

    I don't know if it is possible to work-around the problem, other than handling the failure as mentioned above. Maybe someone else in the forum can suggest a work-around..

  • SudarshanRao
    SudarshanRao
    54 Posts

    Re: Diff is not working for long strings?

    ‏2014-07-28T12:08:29Z  

    There is an upper limit on the size of buffers that can be compared.
    There was a defect logged recently (PI12272), to increase this upper limit. The defect is fixed in v9.6, where the limit was increased. So, your code might work better on v9.6, depending on the size of text that is being compared.

    As per the definition of diff perm:
    The result is valid only when a non-null string is returned.

    So, if the result buffer is null, you could handle that. And, I think it also returns an error when the perm fails.

    I don't know if it is possible to work-around the problem, other than handling the failure as mentioned above. Maybe someone else in the forum can suggest a work-around..

  • etleg
    etleg
    12 Posts

    Re: Diff is not working for long strings?

    ‏2014-07-28T15:51:29Z  

    There is an upper limit on the size of buffers that can be compared.
    There was a defect logged recently (PI12272), to increase this upper limit. The defect is fixed in v9.6, where the limit was increased. So, your code might work better on v9.6, depending on the size of text that is being compared.

    As per the definition of diff perm:
    The result is valid only when a non-null string is returned.

    So, if the result buffer is null, you could handle that. And, I think it also returns an error when the perm fails.

    I don't know if it is possible to work-around the problem, other than handling the failure as mentioned above. Maybe someone else in the forum can suggest a work-around..

    Thank you for the information.

    Updated on 2014-07-28T15:51:45Z at 2014-07-28T15:51:45Z by etleg
  • llandale
    llandale
    3035 Posts

    Re: Diff is not working for long strings?

    ‏2014-07-28T20:53:10Z  

    There is an upper limit on the size of buffers that can be compared.
    There was a defect logged recently (PI12272), to increase this upper limit. The defect is fixed in v9.6, where the limit was increased. So, your code might work better on v9.6, depending on the size of text that is being compared.

    As per the definition of diff perm:
    The result is valid only when a non-null string is returned.

    So, if the result buffer is null, you could handle that. And, I think it also returns an error when the perm fails.

    I don't know if it is possible to work-around the problem, other than handling the failure as mentioned above. Maybe someone else in the forum can suggest a work-around..

    Yes.  Seems to me this works:

    • noError
    • diff(bla bla bla)
    • string ErrMess = lastError()
    • if (!null ErrMess) then results not valid; else results valid

    Also, I think the upper limit of diff() is the number of different tokens ..err.. words in the two buffers; not so much the size of the buffers; at least years ago that's what they said. 

    I'm VERY surprised you could get that much data into a raw text atribute, however.

    -Louie