DOTNET code to WINDEV code

Startbeitrag von Mitchell am 15.02.2013 07:20

who has an idea to convert the code below from DOTNET to WINDEV ?
public int GetTagData(ref byte[,] tag_data, ref byte tag_cnt);

please share....

Antworten:

Hi Mitchell,
a bit more code would help ;)

Consider this C# class :

namespace net4wd
{

public class Test
{

public void FillArray( ref byte[] barr )
{

if (barr == null)
{
barr = new byte[3];

}

barr[0] = 1;
barr[1] = 2;
barr[2] = 3;
}
}
}



and this WD code :

ba is array of byte = [0,0,0]
Test is Test dynamic = new Test()
Test.FillArray( ba )

FOR i = 1 TO ba..Occurrence
Trace( ba )
END


Works so far, I am just ignoring two things You use a 2 dimensional array, I will leave it to you to solve this. Next, and this is a drawBack.
You have know the size of ba ,
in case that I will use :

ba is array of byte // insread of : ba is array of byte = [0,0,0]


You will get a runtime exception.

Or in other words :

if (barr == null)
{
barr = new byte[3];

}

Has no impact at all. AFAIK there is no way to make this work in W language

Regarding the simple ref byte parameter
b is byte
MyNetFunc ( b )


HTH,
#pragma

von Pragma Tix - am 16.02.2013 13:46

Re: DOTNET code to WINDEV code [SOLUTION]

Quote
Mitchell
who has an idea to convert the code below from DOTNET to WINDEV ?
public int GetTagData(ref byte[,] tag_data, ref byte tag_cnt);

please share....


Welll, your function signature tells us a bit ....
I guess that tag_cnt is the number of tags, and byte means max 256 entries.

Ok,here the two dimensional byte array solution
WINDEV code :

ba is array of [256,2] byte // max possible size
nTags is byte

Test is Test dynamic = new Test()
Test.FillArray( ba, nTags)
Dimension( ba, nTags,2 ) // Resize

FOR i = 1 TO nTags
Trace( ba[i,1] + "/" + ba[i,2] )
END


C# code


public class Test
{
//...
public void FillArray( ref byte[,] barr, ref byte nTag )
{
if (barr == null) // Still , this code has no imapact due to limited WD NET support
{
barr = new byte[3,2];

}
nTag = 3;
barr = new byte[,] { {1,2}, {3,4}, {5,6} };
}
}



HTH,
#pragma

von Pragma Tix - am 16.02.2013 14:52
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.