Missing selector
Stephan Rudlof
sr at evolgo.de
Mon Apr 10 13:14:44 UTC 2000
Dear Mark,
I don't like the naming of your method:
!ByteArray methodsFor: 'converting'!
asIntegerFrom: anOffset for: aLength
| shiftAmount anInteger |
shiftAmount := 0.
anInteger := 0.
anOffset to: aLength
do:
[:index |
anInteger := anInteger bitOr: ((self at: index)
bitShift: shiftAmount).
shiftAmount := shiftAmount + 8].
^anInteger! !
You loop from a start index (anOffset) *to* another stop index
(aLength). So I would name this method
ByteArray>>asIntegerFrom: fromIndex to: toIndex
.
If you want to express aLength bytes should be used to construct the
Integer, the method has to be another.
Greetings,
Stephan
"Mark A. Schwenk" wrote:
>
> "Jarvis, Robert P. (Contingent)" wrote:
> >
> > > -----Original Message-----
> > > From: Benoit St-Jean [SMTP:lamneth at aei.ca]
> > > Sent: Sunday, April 09, 2000 12:56 AM
> > > To: Squeak
> > > Subject: Missing selector
> > >
> > > I'm currently using Jdm* classes to access a MySql database.
> > > Everything works fine except for the fact that there seems to be a
> > > selector that used to be present in older versions of Squeak that is no
> > > longer there...
> > >
> > > ByteArray >> asInteger
> > >
> > > I just need this method in order for my little toy to work... Anyone
> > > with the code of ByteArray >> asInteger ???
> > >
> > It looks like #asInteger was replaced by a number of methods, such as
> > #longAt:bigEndian:, #unsignedShortAt:bigEndian, etc. I hope this helps.
> >
> > Bob Jarvis
> > Compuware @ Timken
>
> I have been using the this driver. Perhaps the attached methods from my image will help.
>
> Sorry for the delay, I've been doing some Spring cleaning in my image.
>
> -Mark Schwenk
> WellThot Inc.
>
> ------------------------------------------------------------------------
> Name: ByteArray-asInteger.st
> ByteArray-asInteger.st Type: Plain Text (text/plain)
> Encoding: 7bit
>
> Name: ByteArray-asIntegerFromfor.st
> ByteArray-asIntegerFromfor.st Type: Plain Text (text/plain)
> Encoding: 7bit
--
Stephan Rudlof (sr at evolgo.de)
"Genius doesn't work on an assembly line basis.
You can't simply say, 'Today I will be brilliant.'"
-- Kirk, "The Ultimate Computer", stardate 4731.3
More information about the Squeak-dev
mailing list
|