Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2021-08

Bookmark, TBookmarkStr, TBytes and BytesOf

9 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Santiago A.

Hello:

Freepascal 3.2.0. Windows 7-32bits

TMyObject=class   private     fDset:TDataset;    function
GetBookmark:TBookmarkStr; ... end;
function TMyObject.GetBookmark:TBookmarkStr; Begin  
result:=FDset.Bookmark; end;

I get this compiling error:
Incompatible types: got "TBytes" expected "AnsiString"

Nevertheless, /TbookmarkStr/ documentation example assigns bookmark property to a TBookmarkStr variable
https://www.freepascal.org/docs-html/fcl/db/tdataset.bookmark.html

I have considered to convert the TBytes to AnsiString, but instead to doing a research about AnsiString internals, or creating a function that copies bytes in a loop, I supposed that there was already a function to do that. I found BytesOf
https://www.freepascal.org/docs-html/rtl/sysutils/bytesof.html The abstract is  "Return the bytes in a string", when in fact, according with the text below,  it does the opposite, returns the string in an array of bytes.

Is there any function that move the bytes to an AnsiString?

Saludos Santiago A.

Reply by email

LacaK
to Santiago A.
Show quoted text 12 lines
I have considered to convert the TBytes to AnsiString, but instead to doing a research about AnsiString internals, or creating a function that copies bytes in a loop, I supposed that there was already a function to do that. I found BytesOf https://www.freepascal.org/docs-html/rtl/sysutils/bytesof.html The abstract is  "Return the bytes in a string", when in fact, according with the text below,  it does the opposite, returns the string in an array of bytes. Is there any function that move the bytes to an AnsiString?

AFAICS there is only
https://www.freepascal.org/docs-html/rtl/sysutils/stringof.html L.

Reply by email

Michael Van Canneyt
to Santiago A.: Hello: Freepascal 3.2.0. Windows 7-32bits TMyObject=class   private    …
Santiago A. wrote 16 lines
Hello: Freepascal 3.2.0. Windows 7-32bits TMyObject=class   private     fDset:TDataset;    function GetBookmark:TBookmarkStr; ... end; function TMyObject.GetBookmark:TBookmarkStr; Begin   result:=FDset.Bookmark; end; I get this compiling error: Incompatible types: got "TBytes" expected "AnsiString" Nevertheless, /TbookmarkStr/ documentation example assigns bookmark property to a TBookmarkStr variable https://www.freepascal.org/docs-html/fcl/db/tdataset.bookmark.html

The type used for bookmarks changed over time.

You really must use TBookmark.

I have corrected the documentation, it seems the 2 types were switched when I corrected the documentation when the type actually changed. Sorry about that :/

Michael.

Reply by email

Santi
to Michael Van Canneyt
Michael Van Canneyt wrote 29 lines
On Thu, 26 Aug 2021, Santiago A. via fpc-pascal wrote: > Hello: > > Freepascal 3.2.0. Windows 7-32bits > > TMyObject=class   private     fDset:TDataset;    function > GetBookmark:TBookmarkStr; ... end; > > function TMyObject.GetBookmark:TBookmarkStr; Begin > result:=FDset.Bookmark; end; > > I get this compiling error: > Incompatible types: got "TBytes" expected "AnsiString" > > Nevertheless, /TbookmarkStr/ documentation example assigns bookmark > property to a TBookmarkStr variable > https://www.freepascal.org/docs-html/fcl/db/tdataset.bookmark.html The type used for bookmarks changed over time. You really must use TBookmark. I have corrected the documentation, it seems the 2 types were switched when I corrected the documentation when the type actually changed. Sorry about that :/

So, TbookmarkSr is deprecated and I only have to use TBookmark.

Show quoted text 6 lines
Michael. _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Saludos Santi

Reply by email

Michael Van Canneyt
to Santi
Santi wrote 31 lines
El 26/08/2021 a las 11:58, Michael Van Canneyt via fpc-pascal escribió: > > > On Thu, 26 Aug 2021, Santiago A. via fpc-pascal wrote: > >> Hello: >> >> Freepascal 3.2.0. Windows 7-32bits >> >> TMyObject=class   private     fDset:TDataset;    function >> GetBookmark:TBookmarkStr; ... end; >> >> function TMyObject.GetBookmark:TBookmarkStr; Begin result:=FDset.Bookmark; >> end; >> >> I get this compiling error: >> Incompatible types: got "TBytes" expected "AnsiString" >> >> Nevertheless, /TbookmarkStr/ documentation example assigns bookmark >> property to a TBookmarkStr variable >> https://www.freepascal.org/docs-html/fcl/db/tdataset.bookmark.html > > The type used for bookmarks changed over time. > > You really must use TBookmark. > > I have corrected the documentation, it seems the 2 types were switched when > I corrected the documentation when the type actually changed. Sorry about > that :/ So, TbookmarkSr is deprecated and I only have to use TBookmark.

Yes.

Michael.

Reply by email

Santi
to Michael Van Canneyt: The type used for bookmarks changed over time. You really must use TBookmark. I have…
Michael Van Canneyt wrote 29 lines
On Thu, 26 Aug 2021, Santiago A. via fpc-pascal wrote: > Hello: > > Freepascal 3.2.0. Windows 7-32bits > > TMyObject=class   private     fDset:TDataset;    function > GetBookmark:TBookmarkStr; ... end; > > function TMyObject.GetBookmark:TBookmarkStr; Begin > result:=FDset.Bookmark; end; > > I get this compiling error: > Incompatible types: got "TBytes" expected "AnsiString" > > Nevertheless, /TbookmarkStr/ documentation example assigns bookmark > property to a TBookmarkStr variable > https://www.freepascal.org/docs-html/fcl/db/tdataset.bookmark.html The type used for bookmarks changed over time. You really must use TBookmark. I have corrected the documentation, it seems the 2 types were switched when I corrected the documentation when the type actually changed. Sorry about that :/

By the way, BytesOf documentation is also misleading

Show quoted text 6 lines
Michael. _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Saludos Santi

Reply by email

Michael Van Canneyt
to Santi
Santi wrote 31 lines
El 26/08/2021 a las 11:58, Michael Van Canneyt via fpc-pascal escribió: > > > On Thu, 26 Aug 2021, Santiago A. via fpc-pascal wrote: > >> Hello: >> >> Freepascal 3.2.0. Windows 7-32bits >> >> TMyObject=class   private     fDset:TDataset;    function >> GetBookmark:TBookmarkStr; ... end; >> >> function TMyObject.GetBookmark:TBookmarkStr; Begin result:=FDset.Bookmark; >> end; >> >> I get this compiling error: >> Incompatible types: got "TBytes" expected "AnsiString" >> >> Nevertheless, /TbookmarkStr/ documentation example assigns bookmark >> property to a TBookmarkStr variable >> https://www.freepascal.org/docs-html/fcl/db/tdataset.bookmark.html > > The type used for bookmarks changed over time. > > You really must use TBookmark. > > I have corrected the documentation, it seems the 2 types were switched when > I corrected the documentation when the type actually changed. Sorry about > that :/ By the way, BytesOf documentation is also misleading

In what sense ?

Michael.

Reply by email

Santi
to Michael Van Canneyt
Michael Van Canneyt wrote 38 lines
On Thu, 26 Aug 2021, Santi via fpc-pascal wrote: > El 26/08/2021 a las 11:58, Michael Van Canneyt via fpc-pascal escribió: >> >> >> On Thu, 26 Aug 2021, Santiago A. via fpc-pascal wrote: >> >>> Hello: >>> >>> Freepascal 3.2.0. Windows 7-32bits >>> >>> TMyObject=class   private     fDset:TDataset;    function >>> GetBookmark:TBookmarkStr; ... end; >>> >>> function TMyObject.GetBookmark:TBookmarkStr; Begin >>> result:=FDset.Bookmark; end; >>> >>> I get this compiling error: >>> Incompatible types: got "TBytes" expected "AnsiString" >>> >>> Nevertheless, /TbookmarkStr/ documentation example assigns bookmark >>> property to a TBookmarkStr variable >>> https://www.freepascal.org/docs-html/fcl/db/tdataset.bookmark.html >> >> The type used for bookmarks changed over time. >> >> You really must use TBookmark. >> >> I have corrected the documentation, it seems the 2 types were >> switched when >> I corrected the documentation when the type actually changed. Sorry >> about that :/ > > By the way, BytesOf documentation is also misleading In what sense ?

https://www.freepascal.org/docs-html/rtl/sysutils/bytesof.html The abstract is  "Return the bytes in a string". Probably you can blame my English, but I think it is ambiguous whether  it must be read as

Return (the bytes (in a string))
or
return (the bytes) -> (in a string)

before reading the function declaration, I thought it was the second case.

better something like "Return the bytes OF a string in an array of bytes TBytes"

Show quoted text 6 lines
Michael. _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Saludos Santi

Reply by email

Michael Van Canneyt
to Santi
Santi wrote 19 lines
>>> that :/ >> >> By the way, BytesOf documentation is also misleading > > In what sense ? https://www.freepascal.org/docs-html/rtl/sysutils/bytesof.html The abstract is  "Return the bytes in a string". Probably you can blame my English, but I think it is ambiguous whether  it must be read as Return (the bytes (in a string)) or return (the bytes) -> (in a string) before reading the function declaration, I thought it was the second case. better something like "Return the bytes OF a string in an array of bytes TBytes"

Thanks for pointing it out, I changed it more or less according to your suggestion.

Michael.

Reply by email