Pointers

Jedhi

Centurion
Joined
Oct 2, 2003
Messages
127
I was just wondering what you do in C# when you do not have any pointers. How would you for example do this in C# ?

byte *pData, byte length
byte ix = 0
static byte buffer[100];

for (int i=0;i<length;i++)
buffer[ix++] = pData;
 
You could just use arrays.

C#:
private void CopyArray(byte[] pData)
{
byte ix = 0;
byte[] buffer = new byte[100];

for (int i=0;i<pData.Length;i++)
buffer[ix++] = pData[i];
}

any reason why you need pointers? If so you can mark the code as being unsafe and pointers can be used.
 
I have some problems with callback function. Would you look through the code and correct the errors and send me back the source ?
 
In short term when clicked on the button buttonClick is activated. You send a broadcast to all the nodes by passing the parameters to the function SendData, afterwards it return. And call ActivateAlllNodeswhere it call itself until max number of nodes has been received. I do not know it is easier to look through having all the project.

private void buttonClick(object sender, System.EventArgs e)
{

if (api.SendData(BROADCAST,command,2, ActivateAlllNodes)))
{
m_txtStatus.Text.Insert(1,"OKAY");
}
else
{
m_txtStatus.Text.Insert(1,"FAILING");
}
}

public virtual void ActivateAlllNodes(byte[] command)
{
byte nodeID = 0;
while (nodeID++ < MAX_NODES)
{
if (nodeIDisaccepted)
break;
}
if (nodeID > MAX_NODES)
{
m_txtStatus.Text.Insert(1,"FINISH");
}
else
{
api.SendData(nodeID, command, 2,ActivateAlllNodes);
}
}

public delegate void CompletedFunc(byte b);

public byte SendData(byte nodeID, byte[] pdata, byte dataLength, CompletedFunc cmplfunc)
{
byte byCompletedFunc = ( cmplfunc == NULL? 0: 0x03); and some other stuff here...
}
 
Back
Top