Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

How To Convert Array of Char to String

8 posts in Delphi Last posting was on 2003-09-05 17:15:54.0Z
"Jeff Kreider" Posted on 2003-09-04 18:26:24.0Z
From: "Jeff Kreider" <jeff(-at-)pctournaments.com>
Newsgroups: Advantage.Delphi
Subject: How To Convert Array of Char to String
Date: Thu, 4 Sep 2003 13:26:24 -0500
Lines: 14
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 168.236.254.1
Message-ID: <3f578694@solutions.advantagedatabase.com>
X-Trace: 4 Sep 2003 12:38:12 -0700, 168.236.254.1
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!168.236.254.1
Xref: solutions.advantagedatabase.com Advantage.Delphi:13877
Article PK: 1107313

I am getting the dictionary version value, but do not know how to to convert
the result to a string. The result of the
AdsDictionary.GetDatabaseProperty(ADS_DD_VERSION_MAJOR, @majVersion,
lenBuffer) where majVersion: array[0..2] of char and lenBuffer: UNSIGNED16.
The result of the procedure is: majVersion = [#1,#0,#0] and lenBuffer = 1.

On the flip side how do I convert a string into the format which
SetDatabaseProperty will accept? I haven't had to use these types before,
and am finding them a bit confusing in trying to figure out how to use them.

Thanks,
Jeff


Udo Nesshoever Posted on 2003-09-05 10:08:38.0Z
Message-ID: <bj9uc9.aj.2@nesshoever.net>
From: "Udo Nesshoever" <newsgroup.reply.4@gmx.net>
Newsgroups: Advantage.Delphi
Subject: Re: How To Convert Array of Char to String
Date: Fri, 05 Sep 2003 12:08:38 +0200
References: <3f578694@solutions.advantagedatabase.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 32
NNTP-Posting-Host: 62.225.210.25
X-Trace: 5 Sep 2003 04:10:55 -0700, 62.225.210.25
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!62.225.210.25
Xref: solutions.advantagedatabase.com Advantage.Delphi:13882
Article PK: 1107317

On Thu, 4 Sep 2003 13:26:24 -0500 "Jeff Kreider"

<jeff(-at-)pctournaments.com> wrote:

>I am getting the dictionary version value, but do not know how to to convert
>the result to a string. The result of the
>AdsDictionary.GetDatabaseProperty(ADS_DD_VERSION_MAJOR, @majVersion,
>lenBuffer) where majVersion: array[0..2] of char and lenBuffer: UNSIGNED16.
>The result of the procedure is: majVersion = [#1,#0,#0] and lenBuffer = 1.

just assign it.

var
majVersion: array[0..2] of char;
strVersion: string;
...
strVersion:= majVersion;
// that's it

>On the flip side how do I convert a string into the format which
>SetDatabaseProperty will accept? I haven't had to use these types before,
>and am finding them a bit confusing in trying to figure out how to use them.

var
pw: string;
...
pw:= 'my super hidden password ;)';
...
adsDict.SetDatabaseProperty(ADS_DD_ENCRYPT_TABLE_PASSWORD,
PChar(pw), Length(pw) + 1);

Cheers,
Udo


Tobias Lehnert Posted on 2003-09-05 11:38:58.0Z
From: "Tobias Lehnert" <T.Lehnert@dtzaenker.de>
Newsgroups: Advantage.Delphi
References: <3f578694@solutions.advantagedatabase.com> <bj9uc9.aj.2@nesshoever.net>
Subject: Re: How To Convert Array of Char to String
Date: Fri, 5 Sep 2003 13:38:58 +0200
Lines: 27
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 217.85.117.227
Message-ID: <3f58754f@solutions.advantagedatabase.com>
X-Trace: 5 Sep 2003 05:36:47 -0700, 217.85.117.227
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!217.85.117.227
Xref: solutions.advantagedatabase.com Advantage.Delphi:13883
Article PK: 1107316

Hi,

> >I am getting the dictionary version value, but do not know how to to
convert
> >the result to a string. The result of the
> >AdsDictionary.GetDatabaseProperty(ADS_DD_VERSION_MAJOR, @majVersion,
> >lenBuffer) where majVersion: array[0..2] of char and lenBuffer:
UNSIGNED16.
> >The result of the procedure is: majVersion = [#1,#0,#0] and lenBuffer =
1.
>
> just assign it.
>
> var
> majVersion: array[0..2] of char;
> strVersion: string;
> ...
> strVersion:= majVersion;
> // that's it

Isn't it better to do something like
strVersion := copy(majVersion, 0, lenBuffer); ?
I'm not sure that the complete array is initialized to #0.

Tobias


Udo Nesshoever Posted on 2003-09-05 12:07:53.0Z
Message-ID: <bja5bs.bm.2@nesshoever.net>
From: "Udo Nesshoever" <newsgroup.reply.4@gmx.net>
Newsgroups: Advantage.Delphi
Subject: Re: How To Convert Array of Char to String
Date: Fri, 05 Sep 2003 14:07:53 +0200
References: <3f578694@solutions.advantagedatabase.com> <bj9uc9.aj.2@nesshoever.net> <3f58754f@solutions.advantagedatabase.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 14
NNTP-Posting-Host: 62.225.210.25
X-Trace: 5 Sep 2003 06:10:12 -0700, 62.225.210.25
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!62.225.210.25
Xref: solutions.advantagedatabase.com Advantage.Delphi:13884
Article PK: 1107320


On Fri, 5 Sep 2003 13:38:58 +0200 Tobias Lehnert wrote:

>Isn't it better to do something like
> strVersion := copy(majVersion, 0, lenBuffer); ?
>I'm not sure that the complete array is initialized to #0.

Then you've implicitly converted majVersion to a string as COPY expects
a string as first parameter ;)

But what you could do is
SetLength(s, lenBuffer);

Cheers,
Udo


Tobias Lehnert Posted on 2003-09-05 12:55:04.0Z
From: "Tobias Lehnert" <T.Lehnert@dtzaenker.de>
Newsgroups: Advantage.Delphi
References: <3f578694@solutions.advantagedatabase.com> <bj9uc9.aj.2@nesshoever.net> <3f58754f@solutions.advantagedatabase.com> <bja5bs.bm.2@nesshoever.net>
Subject: Re: How To Convert Array of Char to String
Date: Fri, 5 Sep 2003 14:55:04 +0200
Lines: 23
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 217.85.118.228
Message-ID: <3f588731@solutions.advantagedatabase.com>
X-Trace: 5 Sep 2003 06:53:05 -0700, 217.85.118.228
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!217.85.118.228
Xref: solutions.advantagedatabase.com Advantage.Delphi:13885
Article PK: 1107321

Hallo,

> >Isn't it better to do something like
> > strVersion := copy(majVersion, 0, lenBuffer); ?
> >I'm not sure that the complete array is initialized to #0.
>
> Then you've implicitly converted majVersion to a string as COPY expects
> a string as first parameter ;)
>
> But what you could do is
> SetLength(s, lenBuffer);
>

in the delphi 7.0 help file the copy function is described as

function Copy(S; Index, Count: Integer): string;
function Copy(S; Index, Count: Integer): array;

The typ of S can be a string or an array and the result is a part of the
string or a part of the array.

Tobias


Udo Nesshoever Posted on 2003-09-05 13:26:37.0Z
Message-ID: <bja9vg.c0.2@nesshoever.net>
From: "Udo Nesshoever" <newsgroup.reply.4@gmx.net>
Newsgroups: Advantage.Delphi
Subject: Re: How To Convert Array of Char to String
Date: Fri, 05 Sep 2003 15:26:37 +0200
References: <3f578694@solutions.advantagedatabase.com> <bj9uc9.aj.2@nesshoever.net> <3f58754f@solutions.advantagedatabase.com> <bja5bs.bm.2@nesshoever.net> <3f588731@solutions.advantagedatabase.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 10
NNTP-Posting-Host: 62.225.210.25
X-Trace: 5 Sep 2003 07:30:27 -0700, 62.225.210.25
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!62.225.210.25
Xref: solutions.advantagedatabase.com Advantage.Delphi:13886
Article PK: 1107322


On Fri, 5 Sep 2003 14:55:04 +0200 Tobias Lehnert wrote:

>in the delphi 7.0 help file the copy function is described as ...
>The typ of S can be a string or an array and the result is a part of the
>string or a part of the array.

Whoops. Yep. Right. My bad. Need some weekend ;)

Cheers,
Udo


"Jeff Kreider" Posted on 2003-09-05 15:21:39.0Z
From: "Jeff Kreider" <jeff(-at-)pctournaments.com>
Newsgroups: Advantage.Delphi
References: <3f578694@solutions.advantagedatabase.com> <bj9uc9.aj.2@nesshoever.net>
Subject: Re: How To Convert Array of Char to String
Date: Fri, 5 Sep 2003 10:21:39 -0500
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 168.236.254.1
Message-ID: <3f58aa88@solutions.advantagedatabase.com>
X-Trace: 5 Sep 2003 09:23:52 -0700, 168.236.254.1
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!168.236.254.1
Xref: solutions.advantagedatabase.com Advantage.Delphi:13892
Article PK: 1107328

Udo,
The problem with your solution is that strVersion = #1.#0 . The '#' is not
removed.

On the flip side, that doesn't work either. When I enter a '2', the result
that shows up is 50. When I enter a '0' the result that shows up is 48.
What seems to be happening is the ordinal of the value is being saved to the
major and minor versions and not the actual value.

Jeff

"Udo Nesshoever" <newsgroup.reply.4@gmx.net> wrote in message
news:bj9uc9.aj.2@nesshoever.net...
> On Thu, 4 Sep 2003 13:26:24 -0500 "Jeff Kreider"
> <jeff(-at-)pctournaments.com> wrote:
>
> >I am getting the dictionary version value, but do not know how to to
convert
> >the result to a string. The result of the
> >AdsDictionary.GetDatabaseProperty(ADS_DD_VERSION_MAJOR, @majVersion,
> >lenBuffer) where majVersion: array[0..2] of char and lenBuffer:
UNSIGNED16.
> >The result of the procedure is: majVersion = [#1,#0,#0] and lenBuffer =
1.
>
> just assign it.
>
> var
> majVersion: array[0..2] of char;
> strVersion: string;
> ...
> strVersion:= majVersion;
> // that's it
>
> >On the flip side how do I convert a string into the format which
> >SetDatabaseProperty will accept? I haven't had to use these types
before,
> >and am finding them a bit confusing in trying to figure out how to use
them.
>
> var
> pw: string;
> ...
> pw:= 'my super hidden password ;)';
> ...
> adsDict.SetDatabaseProperty(ADS_DD_ENCRYPT_TABLE_PASSWORD,
> PChar(pw), Length(pw) + 1);
>
> Cheers,
> Udo


Lance Schmidt Posted on 2003-09-05 17:15:54.0Z
From: "Lance Schmidt" <LanceSc@ExtendSys.com>
Newsgroups: Advantage.Delphi
References: <3f578694@solutions.advantagedatabase.com>
Subject: Re: How To Convert Array of Char to String
Date: Fri, 5 Sep 2003 11:15:54 -0600
Lines: 65
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 198.60.232.39
Message-ID: <3f58c4f5@solutions.advantagedatabase.com>
X-Trace: 5 Sep 2003 11:16:37 -0700, 198.60.232.39
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!198.60.232.39
Xref: solutions.advantagedatabase.com Advantage.Delphi:13895
Article PK: 1107331

Hello Jeff,

If I may make a suggestion, I would suggest you look in ddobjects.pas of the
ARC source code. There is existing code in there that will retrieve most if
not all properties you would want. This code also shows how to get the
property in the easiest format to work with as possible. Here is how ARC
gets the major version as a number. You can then call IntToStr to convert
this number to a string.

function TDDA.RefreshDDProperties() : UNSIGNED32;
var
ulErrorCode : UNSIGNED32;
usBufLen : UNSIGNED16;
usCheck : UNSIGNED16;
propertyLength : UNSIGNED16;
begin
{* Snipped a bunch of code *}

{* The rest of these properties can be read even if not ADSSYS *}
propertyLength := SizeOf( UNSIGNED16 ); {* size for user version props
*}
{* Get User Version Major *}
try
FoDictionary.GetDatabaseProperty( ADS_DD_VERSION_MAJOR,
@usCheck,
propertyLength );
except
ON EAdsDatabaseError do
begin
ACE.AdsGetLastError( @ulErrorCode, @aucBuff, @usBufLen );
if ( ( ulErrorCode <> AE_SUCCESS ) and
( ulErrorCode <> AE_PROPERTY_NOT_SET ) ) then
raise;
end;
end;
end;

Best Regards,

Lance Schmidt
Advantage R&D
LanceSc@ExtendSys.com

"Jeff Kreider" <jeff(-at-)pctournaments.com> wrote in message
news:3f578694@solutions.advantagedatabase.com...
> I am getting the dictionary version value, but do not know how to to
convert
> the result to a string. The result of the
> AdsDictionary.GetDatabaseProperty(ADS_DD_VERSION_MAJOR, @majVersion,
> lenBuffer) where majVersion: array[0..2] of char and lenBuffer:
UNSIGNED16.
> The result of the procedure is: majVersion = [#1,#0,#0] and lenBuffer = 1.
>
> On the flip side how do I convert a string into the format which
> SetDatabaseProperty will accept? I haven't had to use these types before,
> and am finding them a bit confusing in trying to figure out how to use
them.
>
> Thanks,
> Jeff
>
>