-2

I am calling data from .dll, I need to have NULL to skip some cases.

int Fn(ref byte xpara[])
setnull(xpara)

The code above gave me an error and setnull() doesn't work for byte[]

Since the data from .dll might have 0s in it, I am using byte[] to avoid stopping by 0. I still need to set a byte[] to null in some cases.

Bill
  • 1
  • 1
    Please show the actual PB code you used (the code in your question isn't valid), and why my proposed answer "doesn't work out". – Frank Alvaro Apr 16 '20 at 12:15

2 Answers2

1

No matter the datatype, you cannot use SetNull on a structure or array.

To reset an array, define another variable that you never add any entries and assign it to the one needing to be reset.

String ls_files[], ls_empty[]

ls_files = ls_empty

Roland Smith
  • 957
  • 4
  • 7
0

You cannot set an array type to Null in PowerBuilder*. The best you can do is to reinitialize the array argument to a local byte[] variable that hasn't been assigned.

function integer Fn(ref byte xpara[]);

   byte l_null[]

   // zero-out the referenced byte array
   xpara = l_null

   return 1

end function

Then you can check the length of the reference argument from the caller (i.e.: UpperBound(byteArray).

* You can set it to null, but the caller would end up with a null object error if it tried to do anything (eg: byteArray[1] = 1) with it.

Frank Alvaro
  • 468
  • 4
  • 12