2009/10/23 Gerard N/A gerardusmerca...@gmail.com:
Could it be that the length indicator bytes of the string are written
to the stream?
Ah, looking at the .WriteAnsiString() implementation, you seem to be
100% correct.
Procedure TStream.WriteAnsiString (const S : String);
Var L : Longint;
2009/10/23 Marco van de Voort mar...@stack.nl:
if length(atext)0 then
WriteBuffer(Atext[1], length(AText)?
I always add a LineEnding character to AText, so the 'if length()'
check is not strictly needed. Sometimes I would like to write a
blank line in my text output. Equivalent of writeln('');
Graeme Geldenhuys schreef:
2009/10/23 Gerard N/A gerardusmerca...@gmail.com:
Could it be that the length indicator bytes of the string are written
to the stream?
Ah, looking at the .WriteAnsiString() implementation, you seem to be
100% correct.
Procedure TStream.WriteAnsiString (const S :
2009/10/23 Graeme Geldenhuys graemeg.li...@gmail.com:
Did you try writing with WriteBuffer(Atext[1], length(AText)?
That works exactly like I intended. Thanks Gerard.
I spoke to soon! :-(
I can view the resulting output.txt file with Midnight Commander
(Linux console file manager), but if I
2009/10/23 Vincent Snijders vsnijd...@vodafonevast.nl:
Otherwise you cannot read it back. :-)
But using .WriteAnsiString() doesn't create a plain text file, so the
result is useless. And as my last post says, the method Gerard
suggested is also not 100%.
It seems extra hard to create a
2009/10/23 Graeme Geldenhuys graemeg.li...@gmail.com:
2009/10/23 Vincent Snijders vsnijd...@vodafonevast.nl:
Otherwise you cannot read it back. :-)
But using .WriteAnsiString() doesn't create a plain text file, so the
result is useless. And as my last post says, the method Gerard
suggested
On Fri, Oct 23, 2009 at 12:21 PM, Graeme Geldenhuys
graemeg.li...@gmail.com wrote:
I can view the resulting output.txt file with Midnight Commander
(Linux console file manager), but if I try and open that file with
Gnome gEdit or Lazarus IDE, it says the file does not look like a text
file
Graeme Geldenhuys schreef:
2009/10/23 Vincent Snijders vsnijd...@vodafonevast.nl:
Otherwise you cannot read it back. :-)
But using .WriteAnsiString() doesn't create a plain text file, so the
result is useless. And as my last post says, the method Gerard
suggested is also not 100%.
It seems
On Fri, Oct 23, 2009 at 12:25, Graeme Geldenhuys
graemeg.li...@gmail.com wrote:
Anyway, so now I'm back to square one - unable to create a plain text
file with TFileStream. :-(
What about:
TFileTextStream = class(TFileStream)
constructor Create...;
procedure WriteStr(const fmt: String; const
2009/10/23 Henry Vermaak henry.verm...@gmail.com:
Maybe you need to put the line endings in manually?
What do you mean? I already append LineEnding to AText, and send that
to WriteAnsiString() call.
--
Regards,
- Graeme -
___
fpGUI - a
Graeme Geldenhuys schreef:
2009/10/23 Vincent Snijders vsnijd...@vodafonevast.nl:
Otherwise you cannot read it back. :-)
But using .WriteAnsiString() doesn't create a plain text file, so the
result is useless.
Is useless for your current use, I admit. Don't use it to create a plain text
2009/10/23 Graeme Geldenhuys graemeg.li...@gmail.com:
2009/10/23 Henry Vermaak henry.verm...@gmail.com:
Maybe you need to put the line endings in manually?
What do you mean? I already append LineEnding to AText, and send that
to WriteAnsiString() call.
That's what I meant (and I just
On 23/10/2009 11:21, Graeme Geldenhuys wrote:
2009/10/23 Graeme Geldenhuys graemeg.li...@gmail.com:
Did you try writing with WriteBuffer(Atext[1], length(AText)?
That works exactly like I intended. Thanks Gerard.
I spoke to soon! :-(
I can view the resulting output.txt file with Midnight
On Friday 23 October 2009 11:58:49 Graeme Geldenhuys wrote:
Maybe TFileStream is not suited for plain text output, and I should
rather use the File type instead?
MSEgui has ttextstream and ttexdatastream, lib/common/kernel/msestream.pas.
Hello Frank,
Friday, October 23, 2009, 12:50:22 PM, you wrote:
FP If you want a text file, why do you not use a variable of type text,
FP instead of a TFileStream? Text is what writes a text file. I think these
FP streams are for saving object state, which means they are binary files
2009/10/23 Aleksa Todorovic alexi...@gmail.com:
constructor Create...;
procedure WriteStr(const fmt: String; const args: array of const);
procedure WriteStr(const s: String);
OK, I managed to solve the problem. I have two units that write to the
output text file. The one unit I fixed by using
2009/10/23 JoshyFun joshy...@gmail.com:
Since Delphi first streams I had never used pascal files anymore,
they are a lot of restrictive, not thread safe and are very tied to
which they expect to read/write.
That's kind-of why I wanted to use TFileStream. I use it for reading
binary data, and
Hi,
I'm reading in a WORD (2 bytes) from a binary file. I can display the
Hex format of that value without a problem, but I would also like to
display the String value of that WORD variable. It's the first 2 bytes
of a file, which contains the magic number of the file.
I would like my program to
2009/10/23 Graeme Geldenhuys graemeg.li...@gmail.com:
Hi,
I'm reading in a WORD (2 bytes) from a binary file. I can display the
As I pressed the Send button, I thought about trying the following.
And it worked! But is this the best way of doing what I want?
type
TWord = record
b1:
On Fri, Oct 23, 2009 at 14:10, Graeme Geldenhuys
graemeg.li...@gmail.com wrote:
Hi,
I'm reading in a WORD (2 bytes) from a binary file. I can display the
Hex format of that value without a problem, but I would also like to
display the String value of that WORD variable. It's the first 2 bytes
2009/10/23 Aleksa Todorovic alexi...@gmail.com:
w: WORD
...
YourString := Chr(Lo(w)) + Chr(Hi(w))
or
YourString := Chr(Hi(w)) + Chr(Lo(w))
Ah, thanks. I was close, I used High() and Low() instead. :-( Dope!
--
Regards,
- Graeme -
___
Graeme Geldenhuys wrote:
Hi,
I'm reading in a WORD (2 bytes) from a binary file. I can display the
Hex format of that value without a problem, but I would also like to
display the String value of that WORD variable. It's the first 2 bytes
of a file, which contains the magic number of the file.
On 23/10/2009, Jeff Wormsley dawor...@comcast.net wrote:
That's dangerous, though, if your magic number's two bytes aren't printable
That should never be a problem for my tool though. The tool I am
writing is specific to the INF help format. The tool dumps the file
structure to a text file. (I
The use of 'array[boolean]' does not mean that the array is true or false,
but rather '0..1'. You indicate a range, not a boolean behavior.
6 and 4 gives 4, and 4 is above the range of 1 (the highest cell of the
array you declared). If you would have cast it to boolean, or provide a
better usage,
Graeme Geldenhuys wrote:
On 23/10/2009, Jeff Wormsley dawor...@comcast.net wrote:
That's dangerous, though, if your magic number's two bytes aren't printable
That should never be a problem for my tool though. The tool I am
writing is specific to the INF help format.
On 23/10/2009, Jeff Wormsley dawor...@comcast.net wrote:
Oh, I was fairly certain of that. Its just these little routines tend to
end up in libraries of handy code. I tend to be overly cautious with some
of these because of that.
Point taken. :-) This code is purposely rewritten and
I would like my program to output the following:
-
Header Section
header.ID(5348h = HS)
...
-
Wouldn't it be more direct to use
Blockwrite(file,header.ID,sizeof(header.ID));
That would make it robust against changes of ID size and would avoid the
many
Hi,
The first item is 31bit and the second item is 1 bit. Does FPC support
a record structure that can define bit level sizes?
uint32_tSearchStart:31;// file offset to full text search table
uint32_tsearchlen:1; // if high bit set, size of
search record size is
You can use bitpacked records:
http://www.google.com/codesearch?hl=enlr=q=bitpacked+record+package%3Ahttp%3A%2F%2Fpasxlibbind
\.googlecode\.comsbtn=Search
Here is an example on how I use it :)
Ido
http://ik.homelinux.org/
On Fri, Oct 23, 2009 at 8:15 PM, Graeme Geldenhuys
On 23/10/2009, Jürgen Hestermann juergen.hesterm...@gmx.de wrote:
Wouldn't it be more direct to use
Blockwrite(file,header.ID,sizeof(header.ID));
I read the complete header structure in one go (155 bytes). I simply
want to output to a text file, a human readable structure of the
complete INF
Graeme Geldenhuys schreef:
On 23/10/2009, Jürgen Hestermann juergen.hesterm...@gmx.de wrote:
Wouldn't it be more direct to use
Blockwrite(file,header.ID,sizeof(header.ID));
I read the complete header structure in one go (155 bytes). I simply
want to output to a text file, a human readable
ik wrote on Fri, 23 Oct 2009:
You can use bitpacked records:
http://www.google.com/codesearch?hl=enlr=q=bitpacked+record+package%3Ahttp%3A%2F%2Fpasxlibbind
\.googlecode\.comsbtn=Search
Here is an example on how I use it :)
No, you cannot use bitpacked records for C header translations.
On 23/10/2009, Jonas Maebe jonas.ma...@elis.ugent.be wrote:
The internal format of bitpacked records is opaque, and it is impossible to
express the alignment requirements of C bitpacked structs or their internal
fields with them.
So you suggest I continue like I was before? Reading that
Graeme Geldenhuys wrote:
The first item is 31bit and the second item is 1 bit. Does FPC support
a record structure that can define bit level sizes?
I've done this kind of thing quite a bit in the past. Usually, I define
a raw version and a clean version, and write two routines to convert
On 23/10/2009, Vincent Snijders vsnijd...@vodafonevast.nl wrote:
You can consider declaring the ID in the header record type as array[1..2]
of char.
As Marco suggested... Char size might not always be the same. I did
however change my header to array[0..1] of byte instead.
--
Regards,
-
On Fri 23 Oct 2009, ik wrote:
The use of 'array[boolean]' does not mean that the array is true or
false, but rather '0..1'. You indicate a range, not a boolean
behavior.
Well, pascal is a typed language, so while I do realize that the
information is stored as false=0 and true=1, and that's
David Emerson wrote:
I did cast it to boolean! That's why it smells like a bug
var
b : boolean;
begin
b := boolean (6 and 4);
writeln (t_or_f [b]);
A type cast does not changes the value. A typecast merely allows you to
store a value into a field of a different type
same for
On Sat, Oct 24, 2009 at 3:26 AM, ik ido...@gmail.com wrote:
Doesn't Pascal have something to offer me to deal with it ?
Bitwise operations + inline functions. Covers most of the needs.
thanks,
dmitry
___
fpc-pascal maillist -
Thanks, Martin -- I'm doing the if/then, and am being reminded of what
typecasting actually does!
On Fri 23 Oct 2009, Martin wrote:
A type cast does not changes the value. A typecast merely allows you
to store a value into a field of a different type
39 matches
Mail list logo