Re: [fpc-pascal]feature request: enhanced "pos"
On 6 mrt 2004, at 07:56, Jeff Pohlmeyer wrote: function PosFrom( const needle:AnsiString; const haystack:AnsiString; StartPt:LongInt):LongInt; var p:pChar; begin Result:=0; if (StartPt <= Length(haystack)) then begin p:=StrPos(pChar(@haystack[StartPt]), pChar(needle)); if ( p <> nil ) then Result:= ( p - @haystack[1] ) + 1; end end; Note that this indeed will only work with ansistrings, as shortstrings are not null-terminated (which strpos expects). Of course, you can pass shortstrings to this routine and they will be converted to ansistrings on the fly, but that will more than negate any possible speed gains you could expect over using the plain "pos" function. Jonas ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal]'record' / 'array' variable types
working on some user-defined variable types for a media database project i'm working on (slowly, oh so slowly). i've defined types for artist and album and track (individual). naturally, there's going to be multiple tracks per album, so i'm assuming that an array would be best to store the track information. so far i have the following to "declare" the record things TArtist = record arName: ansistring; arID: longint; end; TAlbum = record alName: ansistring; alID: longint; alLabel: ansistring; alNumTracks: longint; alYear: longint; alFormat: ansistring; end; TTrack = record trNum: longint; trName: ansistring; trID: longint; end; not sure what to do now, to get that "array" structure working for the track information (the artist / album things working ok as far as i can tell so far). any suggestions or pointers to documentation would be appreciated. ___ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal