Issue with OpenEdge.Core.String.Split on 11.6.3

Posted by ntwatkins on 07-Jul-2017 09:23

I am having an issue with the OpenEdge.Core.String and OpenEdge.Core.Collections.Array classes in 11.6.3.  I am trying to split a String into an Array.  When I call the static Split or non-static Split methods, I am getting an OpenEdge error

Routine Split OpenEdge.Core.String sent called routine String

OpenEdge.Core.String mismatched parameters. (2570)

Error attempting to push run time parameters on the stack. (984)

Sample code that produces this error in 11.6.3 is shown below.

using OpenEdge.Core.* from propath.
using OpenEdge.Core.Collections.* from propath.

define variable x as String no-undo.
define variable a as Array no-undo.

x = new String("this is a test").

a = String:Split(x).



Has anyone seen this before?

Thanks,

Nick Watkins

Posted by Peter Judge on 10-Jul-2017 16:09

There are some, um, interesting behaviours with certain functions and LONGCHARs , which get fixed as as they're found. The ENTRY() function here can return CHAR or LONGCHAR (which it arguably should, since the Value property is defined as LONGCHAR.

    new String(entry(1,obString:Value,pcDelimiter)).

All Replies

Posted by Peter Judge on 10-Jul-2017 09:18

Huh … interesting. It looks like the AVM is having difficulty deciding which method to run.
 
If I run the below, I see the message that fails on line 98. Line 98 is the below which should not be run. FWIW I don’t see this in 11.7.1 but you may want to contact TS if you need a patch/fix.
 
   
    /* Splits: OE.Core.String */
    method public Array Split(input pcDelimiter as character):
        return OpenEdge.Core.String:Split(this-object, pcDelimiter).
    end method.
   
which makes no sense.
 
using OpenEdge.Core.* from propath.
using OpenEdge.Core.Collections.* from propath.
 
session:debug-alert = true.
session:error-stack-trace = true.
 
 
define variable x as String no-undo.
define variable a as Array no-undo.
 
x = new String("this is a test").
 
a = String:Split(x).
 
 
catch e as progress.lang.error.
message
e:getmessage(1) skip(2)
e:callstack
 
view-as alert-box.
 
end.
 
---------------------------
Message (Press HELP to view stack trace)
---------------------------
Routine Split OpenEdge.Core.String sent called routine String OpenEdge.Core.String mismatched parameters. (2570)
 
 
Split OpenEdge.Core.String at line 98  (OpenEdge/Core/String.r)
Split OpenEdge.Core.String at line 85  (OpenEdge/Core/String.r)
C:\devarea\temp\oe116\p85145_Untitled1.ped at line 13  (C:\devarea\temp\oe116\p85145_Untitled1.ped)
---------------------------
OK   Help  
---------------------------
 
 
 

Posted by ntwatkins on 10-Jul-2017 15:49

After doing some more debugging, the code at line 98 is the following:

        do iLoop = 1 to iMax:
            oArray:Add(new OpenEdge.Core.String(entry(iLoop, poValue:Value, pcDelimiter))).
        end.

The issue appears to be with the constructors in the String class.  This can be replicated by trying to create a String using the entry function like above.

using OpenEdge.Core.String.

define variable obString as String no-undo.
define variable pcDelimiter as character no-undo.
define variable obNewString as String no-undo.

assign 
obString = new String("this is a test.")
pcDelimiter = ",".

obNewString = new String(entry(1,obString:Value,pcDelimiter)).

The above code causes the error.  The weird thing is that doing the entry function to a longchar and using that longchar to create the string works.

Posted by Laura Stern on 10-Jul-2017 16:01

There are 2 constructors, one with a CHAR parameter and one with a LONGCHAR parameter.  If you pass a LONGCHAR (or ENTRY(<a longchar>), it should call the constructor that takes a LONGCHAR.  If you pass a character string or a CHARACTER variable, it should call the other one.  Even though you could call either in this case, the one with the CHARACTER parameter is a better match so that's the one it should pick.  This is all pretty vanilla.  But if it's not working, it looks like an AVM bug to me.

Posted by Peter Judge on 10-Jul-2017 16:09

There are some, um, interesting behaviours with certain functions and LONGCHARs , which get fixed as as they're found. The ENTRY() function here can return CHAR or LONGCHAR (which it arguably should, since the Value property is defined as LONGCHAR.

    new String(entry(1,obString:Value,pcDelimiter)).

Posted by ntwatkins on 10-Jul-2017 16:15

This is what I would have thought as well.  Even if the ENTRY function returned a CHARACTER, it should have still worked.  Since the AVM sent an invalid parameter message, it seems that something (the ENTRY function, the AVM, something else?) thinks that something that was not a CHARACTER and not a LONGCHAR was returned.

I will send this to TS as a potential bug.

Thanks,

Nick

Posted by gus bjorklund on 11-Jul-2017 14:20

> On Jul 10, 2017, at 5:10 PM, Peter Judge wrote:

>

> There are some, um, interesting behaviours with certain functions and LONGCHAR

a goal when longchar was added (in v9) was that programming with longchars should be exactly the same as when using char and they should be /mostly/ interchangeable (max length and character set being two obvious differences).

This thread is closed