Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

string to dword

490 views
Skip to first unread message

vm

unread,
Jul 31, 2001, 2:35:38 AM7/31/01
to
Greetings:
How do i convert this

NumberToDial : String;

to this
NumberWritten : DWORD;

Thanks!

--
ôżô
V e r n www.parentpresent.org


Grinder

unread,
Jul 31, 2001, 3:20:22 AM7/31/01
to
I'm not sure if this is what you're asking, but if you want to
put a string like "800-555-1212" into a 4-byte integer, it won't
fit. 4-byte unsigned integers run from 0 to a bit over
4000000000. Even if you try to exclude invalid phone numbers
like "000-000-0000," you won't be able to pack it all into the
integer.

If you just want to strip out non-digit characters, you can use
a loop like this:

function DigitsOnly(const sText: string): string;
var
iChar: Integer;
iBuf: Integer;
begin
iBuf := 0;
SetLength(Result, Length(sText));

for iChar := 1 to Length(sText) do
begin
case sText[iChar] of
'0'..'9':
begin
Inc(iBuf);
Result[iBuf] := sText[iChar];
end;
end;
end;

SetLength(Result, iBuf);
end;


"vm" <v...@gte.net> wrote in message news:3b665045_2@dnews...

vm

unread,
Jul 31, 2001, 4:29:40 AM7/31/01
to
Thanks;
I've already stripped out stuff
it looks like 18005551212.

I see a function StrToInt64Def.
But I'm not clear of terminology
is a Dword 32 or 64 or what?
Thanks!

--
ô¿ô

"Grinder" <gri...@no.spam.maam.com> wrote in message
news:3b665c41$1_2@dnews...

> > ô¿ô

Rudy Velthuis (TeamB)

unread,
Jul 31, 2001, 7:35:43 AM7/31/01
to
In article <3b666b08_2@dnews>, vm says...

> I see a function StrToInt64Def.
> But I'm not clear of terminology
> is a Dword 32 or 64 or what?

DWord is 32 bit.
--
Rudy Velthuis (TeamB)

vm

unread,
Jul 31, 2001, 8:03:48 AM7/31/01
to
Ok, but still
how to convert string to dword?
Thanks!
--
ôżô"Rudy Velthuis (TeamB)" <rvel...@gmx.de> wrote in message
news:MPG.15d0b6666...@newsgroups.borland.com...

Rudy Velthuis (TeamB)

unread,
Jul 31, 2001, 8:04:05 AM7/31/01
to
In article <3b669d30_2@dnews>, vm says...

> Ok, but still
> how to convert string to dword?

If the string fits in a DWord, use StrToIntDef, or StrToInt64Def and use
the lower DWord of that (just and with $FFFFFFFF).
--
Rudy Velthuis (TeamB)

Michael Kelly

unread,
Jul 31, 2001, 5:02:23 PM7/31/01
to
On Mon, 30 Jul 2001 20:35:38 -1000, "vm" <v...@gte.net> wrote:

>Greetings:
>How do i convert this
>
>NumberToDial : String;
>
>to this
>NumberWritten : DWORD;
>
>Thanks!

If you want a 32 bit representation of a string then
get one of the freely available CRC32 implementations.
HyperString Library has one for Delphi. You can download
from Torry's page:
http://homepages.borland.com/torry/text.htm

just search the page for HyperString of EFD Systems


Mike

--

"Only choice is an oxymoron."

--

vm

unread,
Jul 31, 2001, 6:13:04 PM7/31/01
to
In ide Help"
If i 'F1' on Dword, this comes up:
.
type DWORD = Longword;

From there, when i click on SEE ALSO or search for Longword,
'Integer types' comes up:
.
Cardinal 0..4294967295 unsigned 32-bit
Longword 0..4294967295 unsigned 32-bit

How do i make the leap (via documentation) that says dword = longword =
integer
therefore, 'StrToIntDef' is what i am after?
Thanks!.

--
ôżô
V e r n www.parentpresent.org
"Rudy Velthuis (TeamB)" <rvel...@gmx.de> wrote in message

news:MPG.15d0bd23e...@newsgroups.borland.com...

Grinder

unread,
Jul 31, 2001, 8:06:17 PM7/31/01
to
Perhaps it would help if you mentioned why you want to convert
this string to an integer (of any size.)

"vm" <v...@gte.net> wrote in message news:3b674314_1@dnews...

Rudy Velthuis (TeamB)

unread,
Aug 1, 2001, 10:45:01 AM8/1/01
to
In article <3b674809_2@dnews>, Grinder says...

> Perhaps it would help if you mentioned why you want to convert
> this string to an integer (of any size.)

Indeed.

But, Vern and Grinder, please don't quote entire messages.
--
Rudy Velthuis (TeamB)

Kristofer Skaug

unread,
Aug 2, 2001, 3:20:12 AM8/2/01
to

"vm" <v...@gte.net> wrote in message news:3b674314_1@dnews...

>
> How do i make the leap (via documentation) that says dword =
longword =
> integer

If you're in Delphi 3 or earlier, this is basically true, since D3-
did not support unsigned 32-bit integer.
In Delphi 4 and higher, the types Cardinal, dword and longword are
UNsigned integers (0..4giga); whereas integer and longint are SIGNED
integers (-2giga... 2giga).
(I've been clamouring before to have delphi support the clear type
names Int16/Int32 and UInt16/UInt32 since it is certainly not obvious
that 'longword' and 'longint' hold the same number of bits but the
difference is in the signed thing.

> therefore, 'StrToIntDef' is what i am after?

No, it looks to me like you need StrToInt64(Def) to hold your 10-digit
phone numbers (you may also need to consider the requirements of
international access codes? in that case you might run up several
additional digits).

Kristofer


vm

unread,
Aug 2, 2001, 1:33:14 PM8/2/01
to
clamour on my friend.
Thanks!
--
ô¿ô"Kristofer Skaug" <k.s...@satserv.nl> wrote in message
news:3b68fe99$1_2@dnews...

vm

unread,
Aug 2, 2001, 1:34:25 PM8/2/01
to
Thanks for the reminder.

Ray Lischner

unread,
Aug 2, 2001, 1:29:49 PM8/2/01
to
Kristofer Skaug wrote:

> In Delphi 4 and higher, the types Cardinal, dword and longword are
> UNsigned integers (0..4giga); whereas integer and longint are SIGNED
> integers (-2giga... 2giga).

Let us be precise.

LongInt and LongWord are 32-bits.

Integer and Cardinal are the natural size of an integer. In a future
release, I fully expect them to grow to be 64 bits.

DWORD is whatever Microsoft deems it to be, as translated by Borland. I
don't know if DWORD will be 32 bits or 64 bits in a 64-bit Windows OS
of the future.
--
Ray Lischner, author of Delphi in a Nutshell
http://www.tempest-sw.com

Kristofer Skaug

unread,
Aug 3, 2001, 8:14:06 AM8/3/01
to

"vm" <v...@gte.net> wrote in message news:3b698d65_1@dnews...
> clamour on my friend.

I am considering launching a major campaign for D7... <g>
Kristofer


Kristofer Skaug

unread,
Aug 3, 2001, 8:21:20 AM8/3/01
to
"Ray Lischner" <donts...@spam.you> wrote in message
news:1875681.A...@tempest-sw.com...
>
> Let us be precise.
>

you mean as opposed to using terms like "the signed thing?" (my own
words, <g>).

> LongInt and LongWord are 32-bits.

On a side note to these names, what do you think should
happen when 64- and 128- bit integers become the norm?
We call those "DoubleLongInt" and "QuadrupleLongInt"? <g>
[just to have a delphi native typename which fits in the sequence]

> Integer and Cardinal are the natural size of an integer. In a future
> release, I fully expect them to grow to be 64 bits.

Natural for whom? I think that 64-bit hardware and OS would
be a prerequisite.

> DWORD is whatever Microsoft deems it to be, as translated by
Borland. I
> don't know if DWORD will be 32 bits or 64 bits in a 64-bit Windows
OS
> of the future.

if they *dare* to redefine DWORD I'm going to ...
<gurgle of self-censorship>
... be disappointed.

Kristofer

0 new messages