Luciano de Souza | 1 Feb 04:23
Picon

FormatDatetime is not respecting the specified pattern

    Hello listers,

 A strange error came up when formating a date. See this code:
writeln(formatdatetime('dd/mm/YYYY', now));
The answer should be: 31/01/2012
The answer was: 31-01-2012
I did one test else:
writeln(formatdatetime('dd$mm$YYYY', now));
The answer was: 31$01$2012
Yes, the problem seems to be related to the backslash.
DefaultFormatSettings.DateSeparator := '/';
writeln(formatdatetime('dd/mm/YYYY', now));
The answer was: 31/01/2012
Right! That's the answer. But it was necessary to setup the settings manually.
The test was done with Freepascal 2.4.4 and Ubuntu 10.10.
Does someone know what is my mistake?
Regards,
Luciano
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
waldo kitty | 1 Feb 07:54
X-Face
Favicon

Re: FormatDatetime is not respecting the specified pattern

On 1/31/2012 22:23, Luciano de Souza wrote:
> Hello listers,
>
> A strange error came up when formating a date. See this code:
> writeln(formatdatetime('dd/mm/YYYY', now));
> The answer should be: 31/01/2012
> The answer was: 31-01-2012
> I did one test else:
> writeln(formatdatetime('dd$mm$YYYY', now));
> The answer was: 31$01$2012
> Yes, the problem seems to be related to the backslash.

errrm1... that's not a 'back slash'... that's a "forward" slash.. aka just a 
plain slash... "back slash" leans backwards (ie: top to the left)...

> DefaultFormatSettings.DateSeparator := '/';
> writeln(formatdatetime('dd/mm/YYYY', now));
> The answer was: 31/01/2012
> Right! That's the answer. But it was necessary to setup the settings manually.
> The test was done with Freepascal 2.4.4

errrm2: FP 2.6.0 is the current release... unless i'm highly mistaken... but 
still, see higher above ;)

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Favicon

Re: FormatDatetime is not respecting the specified pattern


On Wed, 1 Feb 2012, Luciano de Souza wrote:

>     Hello listers,
> 
>  A strange error came up when formating a date. See this code:
> writeln(formatdatetime('dd/mm/YYYY', now));
> The answer should be: 31/01/2012
> The answer was: 31-01-2012
> I did one test else:
> writeln(formatdatetime('dd$mm$YYYY', now));
> The answer was: 31$01$2012
> Yes, the problem seems to be related to the backslash.
> DefaultFormatSettings.DateSeparator := '/';
> writeln(formatdatetime('dd/mm/YYYY', now));
> The answer was: 31/01/2012
> Right! That's the answer. But it was necessary to setup the settings manually.
> The test was done with Freepascal 2.4.4 and Ubuntu 10.10.
> Does someone know what is my mistake?

There is no mistake, all is as it should be.

In the format string for FormatDateTime, a / means 'use the date separator of the RTL'.

By default, on linux the RTL date separator is the '-' character.

If you want to initialize the RTL locale settings with the system settings,
just put 'clocale' as one of the first units in your uses clause. 
It will set all necessary constants.

if you want an actual / character in your output, you should do a

writeln(formatdatetime('dd"/"mm"/"YYYY', now));

i.e. enclose the special character in double quotes.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
silvioprog | 1 Feb 10:29
Picon
Gravatar

Re: FormatDatetime is not respecting the specified pattern

2012/2/1 Michael Van Canneyt <michael@...>:
> On Wed, 1 Feb 2012, Luciano de Souza wrote:
>>     Hello listers,
>>
>>  A strange error came up when formating a date. See this code:
>> writeln(formatdatetime('dd/mm/YYYY', now));
>> The answer should be: 31/01/2012
>> The answer was: 31-01-2012
>> I did one test else:
>> writeln(formatdatetime('dd$mm$YYYY', now));
>> The answer was: 31$01$2012
>> Yes, the problem seems to be related to the backslash.
>> DefaultFormatSettings.DateSeparator := '/';
>> writeln(formatdatetime('dd/mm/YYYY', now));
>> The answer was: 31/01/2012
>> Right! That's the answer. But it was necessary to setup the settings
>> manually.
>> The test was done with Freepascal 2.4.4 and Ubuntu 10.10.
>> Does someone know what is my mistake?
>
> There is no mistake, all is as it should be.
>
> In the format string for FormatDateTime, a / means 'use the date separator
> of the RTL'.
>
> By default, on linux the RTL date separator is the '-' character.
>
> If you want to initialize the RTL locale settings with the system settings,
> just put 'clocale' as one of the first units in your uses clause. It will
> set all necessary constants.
>
> if you want an actual / character in your output, you should do a
>
> writeln(formatdatetime('dd"/"mm"/"YYYY', now));
>
> i.e. enclose the special character in double quotes.
>
> Michael.

o.o'

Very nice explanation. Thank you! :)

--

-- 
Silvio Clécio
====================================
Site - <silvioprog.com.br>
LazSolutions - <code.google.com/p/lazsolutions>
====================================
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Luciano de Souza | 1 Feb 12:17
Picon

Re: FormatDatetime is not respecting the specified pattern

Oh! Your correction is really good and welcome. Becouse of a Leber 
Congenital Amaurosis, I became blind when I was a child. As a 
consequence, nowadays, for me, slashes and backslashes are only a word 
spoken by the screen reader. It's really curious how brains can work 
differrently.

When people know you are blind, they don't use to make this kind of 
comment. I am lucky becouse you don't know it! Yes, if the shape of 
slashes and backslashes were similar to a triangle or a castle, it 
wouldn't matter for my daily life. In spite of this, it's really 
intersting to know how things exist in the visual world.

Even screen readers are worried in supplying some visual information. 
NVDA, the screen reader I currently use, can speak the RGB code on a 
particular point. Other screen readers can be more: they can also speak 
the name of the color. Some time ago, using this feature, I knew a color 
called "brick". Brick as a color? It's really intersting. Yes, this 
information is not very important in my life, but at the point of view 
of culture, of the visual culture, it's really curious.

For these reasons, I like Pascal intensively. The two first screen 
readers, these technological wonder, I have been using, they are 
developed in Pascal: Dosvox and Virtual Vision, both conceived by 
brazilian developers.

Welll, well, let me stop the message. If I say something more off topic, 
I will be likely talking about planets and galaxes!

Thank you very much!

Regards,

Luciano

Em 01/02/2012 04:54, waldo kitty escreveu:
> On 1/31/2012 22:23, Luciano de Souza wrote:
>> Hello listers,
>>
>> A strange error came up when formating a date. See this code:
>> writeln(formatdatetime('dd/mm/YYYY', now));
>> The answer should be: 31/01/2012
>> The answer was: 31-01-2012
>> I did one test else:
>> writeln(formatdatetime('dd$mm$YYYY', now));
>> The answer was: 31$01$2012
>> Yes, the problem seems to be related to the backslash.
>
> errrm1... that's not a 'back slash'... that's a "forward" slash.. aka 
> just a plain slash... "back slash" leans backwards (ie: top to the 
> left)...
>
>> DefaultFormatSettings.DateSeparator := '/';
>> writeln(formatdatetime('dd/mm/YYYY', now));
>> The answer was: 31/01/2012
>> Right! That's the answer. But it was necessary to setup the settings 
>> manually.
>> The test was done with Freepascal 2.4.4
>
> errrm2: FP 2.6.0 is the current release... unless i'm highly 
> mistaken... but still, see higher above ;)
>
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal@...
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

--

-- 
Luciano de Souza
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Luciano de Souza | 1 Feb 12:38
Picon

Re: FormatDatetime is not respecting the specified pattern

Oh! Very well! I am blind, for me, slashes and backslashes are only 
words spoken by the screen reader. The worst is I listen "barra" and 
"barra invertida", the portuguese correspondent words. You can imagine: 
I don't see slashes and I listen differently. The chance of mistake is 
very high! But fortunately, I have a good friend who corrects me! One 
bilion of corrections else and I will be perfect!

Thank you very much!

Em 01-02-2012 04:54, waldo kitty escreveu:
> On 1/31/2012 22:23, Luciano de Souza wrote:
>> Hello listers,
>>
>> A strange error came up when formating a date. See this code:
>> writeln(formatdatetime('dd/mm/YYYY', now));
>> The answer should be: 31/01/2012
>> The answer was: 31-01-2012
>> I did one test else:
>> writeln(formatdatetime('dd$mm$YYYY', now));
>> The answer was: 31$01$2012
>> Yes, the problem seems to be related to the backslash.
>
> errrm1... that's not a 'back slash'... that's a "forward" slash.. aka 
> just a plain slash... "back slash" leans backwards (ie: top to the 
> left)...
>
>> DefaultFormatSettings.DateSeparator := '/';
>> writeln(formatdatetime('dd/mm/YYYY', now));
>> The answer was: 31/01/2012
>> Right! That's the answer. But it was necessary to setup the settings 
>> manually.
>> The test was done with Freepascal 2.4.4
>
> errrm2: FP 2.6.0 is the current release... unless i'm highly 
> mistaken... but still, see higher above ;)
>
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal@...
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Malcolm Poole | 1 Feb 19:33
Picon

lNet and TCP packet length

I'm working on a client/server project which involves sending SQL 
commands from server to client and vice versa.

I've been using the LTCP component for both the client and the server, 
which have been working perfectly during testing on the same machine and 
between different virtual machines, sending and receiving packets of 
data several thousand bytes in length.

However, when connecting over ethernet or the internet there appears to 
be a packet limit of 1036 bytes and any packets of data larger than this 
are truncated. I assume this is to do with maximum permissible transport 
units in the routers forming the connections and I was mistaken in 
believing that the lNet TCP implementation would take care of breaking 
the data down into transmissible packets and reassembling them at the 
destination.

Before I set out to implement the procedures to do this myself, can 
someone reassure me that this needs to be done and that I am not 
re-inventing the wheel?

Malcolm
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Vladimir Zhirov | 1 Feb 21:02
Picon

Re: libQT4Pas - Why it is needed?

> Do other languages like python use the plain c interface, or
> C++?
> how about something like ruby, lua, objective C, php ..

AFAIK, Lua uses automatically generated plain C binding.
When I looked at it, the binding generator consisted of
the following parts: 
1) A C++-based program to parse C++ source and extract
   required information as XML;
2) A Lua program to build plain C binding based on this XML
3) A CMake scripts to manage building of the above parts
   and generated binding itself.

The corresponding source code is hosted here:
https://github.com/mkottman/lqt
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

waldo kitty | 1 Feb 21:21
X-Face
Favicon

replace one field of a record in a collection...


i've gone brain dead after a few days at my $$$ job and i cannot figure out how 
to replace one field of a record in a collection :/  i'm looking at my existing 
code that does something similar but it is replacing the entire record and 
that's too much as well as the fact that the two records i'm working with are 
not the same...

i'm building a record with data from a file... this record has a field that is 
basically the joiner between two tables if we were talking databases... all data 
is linked based on this field... there is another field that contains some 
text... is it this text field that needs to be put in place of the text field in 
the collection record if the two are not the same..

so, i'm creating a record to use for the collection's search function but then 
when i find the record i'm seeking, i don't know how to replace its text 
field... the more i look at the code and try to figure it out, the more it looks 
like tarzan's squiggly bugs in the books that he learned to read from :?

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Graeme Geldenhuys | 1 Feb 23:03
Picon
Gravatar

TStringStream.DataString returns garbage?

Hi,

What am I doing wrong in the following code? It always fails on test
number 2. The DataString property is returning garbage, and not the
value equal to the 'Graeme Geldenhuys' string.

----------------------------------------------
var
  srcstream: TStringStream;
  s, f: string;
  i: integer;
begin
  s := 'Graeme Geldenhuys';
  srcstream := TStringStream.Create('');
  { I purposely do this, because in my real-world code TStringStream will
    be populated with many .Write() statements. }
  i := srcstream.Write(s, Length(s));
  CheckEquals(i, Length(s), 'failed on length of string');    // passes
  srcstream.Seek(0, soFromBeginning); // not sure if needed
  f := srcstream.DataString;
  CheckEquals(s, f, 'Failed on string content 2');    // Fails!
  srcstream.Free;
end;
----------------------------------------------

--

-- 
Regards,
  - Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Gmane