I am using the following function (Pascal) to convert a string (10/2/01)
into Mo, Dy and Yr, and I think it does not demonstrate a "clean and
simple" method of accomplishing this task. It would be helpful to me
and others if someone proficient in "C" could show a better way.
Many thanks.........
Todd
function StrToDate(Str: PChar; var Month,Day,Year:Int16): Boolean;
var
i, j: Integer;
ct: Integer;
IntBuf: array[0..10] of char;
Tmp: array[0..10] of char;
s: PChar;
begin
Result := False;
ct := 0;
j := 0;
for i := 0 to StrLen(Str) - 1 do
begin
if Str[i] = '/' then
begin
Inc(ct);
case ct of
1:
begin
StrNCopy(IntBuf, @Str[0], j);
IntBuf[j] := #0;
Month := StrAtoI(IntBuf);
j := 0;
end;
2:
begin
Day := StrAtoI(IntBuf);
StrNCopy(IntBuf, @Str[i-j+1], j-1);
IntBuf[j] := #0;
Day := StrAtoI(IntBuf);
StrCopy(IntBuf, @Str[i+1]);
Year := StrAtoI(IntBuf);
Result := True
end;
end;
end;
Inc(j);
end;
end;
--
Todd Cary
Ariste Software
[EMAIL PROTECTED]
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/