it's because mIRC's data parameter in the function is used for input and also output.

Once you have finished garnishing the data you need in data, reset it simply by doing

data[0] = 0;

then proceed with your normal stuff, if a match is found in the DLL your copy functions will overide this, else, the dll will return an empty string which is equivalent to $null in mIRC.