|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
Gambas equivilent helpVery simple question that i cant seem to answer on my own: What is the gambas equivilent of the java BitSet class? is it a Byte[] array? i dont know but thats about the only thing i could think of.
|
|
|
Re: Gambas equivilent help> Very simple question that i cant seem to answer on my own: What is the
> gambas equivilent of the java BitSet class? is it a Byte[] array? i dont > know but thats about the only thing i could think of. > There is no equivalent of the Java BitSet class. You must implement it by your own, and you can use a Byte array for that if you want. Regards, -- Benoît Minisini ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Gambas equivilent helpI'm trying to convert some java code to Gambas and i cant seem to get it to work at all here is the code.
private BitSet a(BitSet bitset) { BitSet bitset1 = new BitSet(64); boolean flag = false; for(int i1 = 0; i1 < 64; i1++) { if(flag != bitset.get(i1)) bitset1.set(i1); flag = bitset.get(i1); } return bitset1; }
|
|
|
Re: Gambas equivilent helpPrivate Function a( BitSet as Byte[]) as Byte[]
Dim BitSet1 as New Byte[64] Dim Flag as Boolean = false Dim i As Integer For i = 0 to 64-1 If Flag<>BitSet[i] Then BitSet1[i]=True Flag = BitSet[i] Next return BitSet1 2009/10/25 briansykes <brisykes@...>: > > I'm trying to convert some java code to Gambas and i cant seem to get it to > work at all here is the code. > > private BitSet a(BitSet bitset) > { > BitSet bitset1 = new BitSet(64); > boolean flag = false; > for(int i1 = 0; i1 < 64; i1++) > { > if(flag != bitset.get(i1)) > bitset1.set(i1); > flag = bitset.get(i1); > } > > return bitset1; > } > > > Benoît Minisini wrote: >> >>> Very simple question that i cant seem to answer on my own: What is the >>> gambas equivilent of the java BitSet class? is it a Byte[] array? i dont >>> know but thats about the only thing i could think of. >>> >> >> There is no equivalent of the Java BitSet class. You must implement it by >> your >> own, and you can use a Byte array for that if you want. >> >> Regards, >> >> -- >> Benoît Minisini >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> http://p.sf.net/sfu/devconference >> _______________________________________________ >> Gambas-user mailing list >> Gambas-user@... >> https://lists.sourceforge.net/lists/listinfo/gambas-user >> >> > > -- > View this message in context: http://www.nabble.com/Gambas-equivilent-help-tp26044750p26048007.html > Sent from the gambas-user mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Gambas-user mailing list > Gambas-user@... > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Gambas equivilent helpSorry i hit the wrong link, but here it is again. sorry.
private BitSet a(char ac[]) { int i1 = ac.length * 8; BitSet bitset = new BitSet(i1); for(int j1 = 0; j1 < i1; j1++) { int k1 = j1 & 7; int l1 = j1 >> 3; if((ac[l1] & 0xff & 1 << 7 - k1) != 0) ' This is the thing i cant understand. bitset.set(j1); } return bitset; } Private Function a2(ac As String) as Byte[] Dim i1 as Integer Dim bitset as Byte[] Dim j1 as Integer Dim l1 as Integer Dim k1 as Integer i1 = Len(ac) * 8 bitset = New Byte[i1] For j1 = 0 To i1 k1 = j1 AND 7 l1 = Lsr(j1, 3) 'If statement here Next Return bitset End And this is the third function, i have 4 in total i'm trying to convert to Gambas, like the one above i'm stuck on the one line. private char[] a(BitSet bitset, int i1) { int j1 = i1 * 8; char ac[] = new char[i1]; for(int k1 = 0; k1 < j1; k1++) { int l1 = k1 & 7; int i2 = k1 >> 3; if(bitset.get(k1)) ac[i2] = (char)(ac[i2] | 1 << 7 - l1); } return ac; } Private Function a3(bitset as Byte[], i1 as Integer) As String[] Dim j1 as Integer Dim ac as String[] Dim k1 as Integer Dim l1 as Integer Dim i2 as Integer j1 = i1 * 8 ac = New String[i1] For k1 = 0 To j1 l1 = k1 AND 7 i2 = Lsr(k1, 3) If bitset[k1] = True Then Next Return ac End
|
|
|
Re: Gambas equivilent help2009/10/25 briansykes <brisykes@...>:
> > Sorry i hit the wrong link, but here it is again. sorry. > > private BitSet a(char ac[]) > { > int i1 = ac.length * 8; > BitSet bitset = new BitSet(i1); > for(int j1 = 0; j1 < i1; j1++) > { > int k1 = j1 & 7; > int l1 = j1 >> 3; > if((ac[l1] & 0xff & 1 << 7 - k1) != 0) ' This is the thing i > cant understand. > bitset.set(j1); > } > > return bitset; > } > > Private Function a2(ac As String) as Byte[] > Dim bitset as Byte[] Dim j1 as Integer Dim l1 as Integer Dim k1 as Integer i1 = Len(ac) * 8 bitset = New Byte[i1] For j1 = 0 To i1-1 k1 = j1 AND 7 l1 = Lsr(j1, 3) > 'If statement here if cbool(mid(ac,l1)) and $HFF and Lsl(1,7) <>0 then bitset[j1]=true > Next > Return bitset > > End > it's a try but i've not the given value.... is it a boolean string ? ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Gambas equivilent helpThese functions are part of a chat server handshake and they only have it available to me in java so i have to port it to gambas to use it.
I'll post the big function so you can get an idea of what is going on. private void n(String s1) { boolean flag = false; String as[] = { "MNfw9809", "90981qFS", "412.Fdq.", "..13fS4.", "41!!vs%&" }; StringTokenizer stringtokenizer = new StringTokenizer(s1 + "#", "#"); BitSet bitset = new BitSet(64); for(int i1 = 0; i1 < 5; i1++) { BitSet bitset1 = a(as[i1].toCharArray()); int j1 = Integer.parseInt(stringtokenizer.nextToken()); for(int l1 = 0; l1 < j1; l1++) bitset1 = a(bitset1); bitset.xor(bitset1); } char ac[] = a(bitset, 8); for(int k1 = 0; k1 < 8; k1++) if(ac[k1] == 0 || ac[k1] == '\n' || ac[k1] == '\r') ac[k1] = (char)(ac[k1] | 0x80); try { a_java_io_DataOutputStream_fld.writeBytes("~b#" + 13 + "#"); for(int i2 = 0; i2 < ac.length; i2++) a_java_io_DataOutputStream_fld.write((byte)(ac[i2] & 0xff)); a_java_io_DataOutputStream_fld.writeBytes("\n"); a_java_io_DataOutputStream_fld.flush(); return; } catch(Exception exception) { a(exception); } } The "MNfw9809", "90981qFS", "412.Fdq.", "..13fS4.", "41!!vs%&" are the things you have to use when you get the server's handshake request which looks like this: ~a#50#43#32#21#24# And from what i can tell the string array above has to be xor'd with those numbers i think, so thats what i'm trying to do.
|
|
|
Re: Gambas equivilent helpi think Benoit is better at this game than me :/
2009/10/26 briansykes <brisykes@...>: > > These functions are part of a chat server handshake and they only have it > available to me in java so i have to port it to gambas to use it. > > I'll post the big function so you can get an idea of what is going on. > > private void n(String s1) > { > boolean flag = false; > String as[] = { > "MNfw9809", "90981qFS", "412.Fdq.", "..13fS4.", "41!!vs%&" > }; > StringTokenizer stringtokenizer = new StringTokenizer(s1 + "#", > "#"); > BitSet bitset = new BitSet(64); > for(int i1 = 0; i1 < 5; i1++) > { > BitSet bitset1 = a(as[i1].toCharArray()); > int j1 = Integer.parseInt(stringtokenizer.nextToken()); > for(int l1 = 0; l1 < j1; l1++) > bitset1 = a(bitset1); > > bitset.xor(bitset1); > } > > char ac[] = a(bitset, 8); > for(int k1 = 0; k1 < 8; k1++) > if(ac[k1] == 0 || ac[k1] == '\n' || ac[k1] == '\r') > ac[k1] = (char)(ac[k1] | 0x80); > > try > { > a_java_io_DataOutputStream_fld.writeBytes("~b#" + 13 + "#"); > for(int i2 = 0; i2 < ac.length; i2++) > a_java_io_DataOutputStream_fld.write((byte)(ac[i2] & 0xff)); > > a_java_io_DataOutputStream_fld.writeBytes("\n"); > a_java_io_DataOutputStream_fld.flush(); > return; > } > catch(Exception exception) > { > a(exception); > } > } > > The "MNfw9809", "90981qFS", "412.Fdq.", "..13fS4.", "41!!vs%&" are the > things you have to use when you get the server's handshake request which > looks like this: ~a#50#43#32#21#24# And from what i can tell the string > array above has to be xor'd with those numbers i think, so thats what i'm > trying to do. > > > Fabien Bodard-4 wrote: >> >> 2009/10/25 briansykes <brisykes@...>: >>> >>> Sorry i hit the wrong link, but here it is again. sorry. >>> >>> private BitSet a(char ac[]) >>> { >>> int i1 = ac.length * 8; >>> BitSet bitset = new BitSet(i1); >>> for(int j1 = 0; j1 < i1; j1++) >>> { >>> int k1 = j1 & 7; >>> int l1 = j1 >> 3; >>> if((ac[l1] & 0xff & 1 << 7 - k1) != 0) ' This is the thing i >>> cant understand. >>> bitset.set(j1); >>> } >>> >>> return bitset; >>> } >>> >>> Private Function a2(ac As String) as Byte[] >>> >> Dim i1 as Integer >> Dim bitset as Byte[] >> Dim j1 as Integer >> Dim l1 as Integer >> Dim k1 as Integer >> >> i1 = Len(ac) * 8 >> bitset = New Byte[i1] >> For j1 = 0 To i1-1 >> k1 = j1 AND 7 >> l1 = Lsr(j1, 3) >>> 'If statement here >> if cbool(mid(ac,l1)) and $HFF and Lsl(1,7) <>0 then bitset[j1]=true >>> Next >>> Return bitset >>> >>> End >>> >> >> it's a try but i've not the given value.... is it a boolean string ? >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> http://p.sf.net/sfu/devconference >> _______________________________________________ >> Gambas-user mailing list >> Gambas-user@... >> https://lists.sourceforge.net/lists/listinfo/gambas-user >> >> > > -- > View this message in context: http://www.nabble.com/Gambas-equivilent-help-tp26044750p26052874.html > Sent from the gambas-user mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Gambas-user mailing list > Gambas-user@... > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Gambas equivilent helpI've been reading up on java trying to understand it but i just never could get that damn language, some things are similar enough that with a bit of reading i'm able to find the gambas equivilent but other things i cant figure out.
|
| Free embeddable forum powered by Nabble | Forum Help |