Recent

Author Topic: Function Time and blank result  (Read 20036 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Function Time and blank result
« on: February 03, 2010, 08:07:24 am »
I'm creating a program already quite large, so I used the time function successfully, the other day but always within the program I used the time and now I no longer restitute result! But if I open a new project and try to run the time it works! Who can explain why?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Function Time and blank result
« Reply #1 on: February 03, 2010, 08:31:46 am »
Quote
Who can explain why?
Only God can :P
At least post the problematic code along with its dependencies (variables, const, types, used relevant procs/funcs, etc.). We're not seers.

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Function Time and blank result
« Reply #2 on: February 03, 2010, 09:35:03 am »
No, it is a program designed directly with Lazarus.
Well, to tell me if I write

ShowMessage (TimeToStr (Time));

I return an empty string!
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Function Time and blank result
« Reply #3 on: February 03, 2010, 10:02:25 am »
Ubuntu 9.10 amd64
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Function Time and blank result
« Reply #4 on: February 03, 2010, 10:13:17 am »
As I said, replicate the error does not happen in other programs, but within that project always true.
I would not like there was something that sends conflicting. If we take the project and I do run on Windows this works fine! The fact is that I need to run it on ubuntu!
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Function Time and blank result
« Reply #5 on: February 03, 2010, 10:49:48 am »
Assume you have 64 version of Ubuntu and FPC and Lazarus for 64-bit...

I cannot tell what is the problem, perhaps some background/foreground color mix-up...

Try to put statical text in your ShowMessage instead of time function conversion. If you get empty string you need to debug your app...

I do not understand what you mean
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Function Time and blank result
« Reply #6 on: February 03, 2010, 11:29:27 am »
What happens if you do this?
(Needs LCLProc unit)

Code: [Select]
  debugln(DbgS(Time),' "',TimeToStr (Time),'"');

It should output something like:
5.00102650462963E-001 "12:00:08"

(Output will appear on the console, so you'll have to start it from a console (I guess).)

Bart

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Function Time and blank result
« Reply #7 on: February 03, 2010, 12:25:09 pm »
What happens if you do this?
(Needs LCLProc unit)

Code: [Select]
 debugln(DbgS(Time),' "',TimeToStr (Time),'"');

It should output something like:
5.00102650462963E-001 "12:00:08"

(Output will appear on the console, so you'll have to start it from a console (I guess).)

Bart

Result:

[WARNING] Out of OEM specific VK codes, changing to unassigned
[WARNING] Out of unassigned VK codes, assigning $FF
0,51580658564814 ""
« Last Edit: February 03, 2010, 12:32:35 pm by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Function Time and blank result
« Reply #8 on: February 03, 2010, 12:57:02 pm »

Result:

[WARNING] Out of OEM specific VK codes, changing to unassigned
[WARNING] Out of unassigned VK codes, assigning $FF
0,51580658564814 ""

Are you copy some code from webpage? IIRC, simple copy and paste sometimes add some $FF on Linux.  Perhaps that is the problem, cleanup your code from $FF.
How do I?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Function Time and blank result
« Reply #9 on: February 03, 2010, 01:24:38 pm »
DeCodeTime (Time,Hh,MM,SS,MS);
Writeln ('Present Time is : ',FormatDateTime('hh:mm:ss',EnCodeTime (HH,MM,SS,MS)));
writeln('Prova: ',TimeToStr(Time));


The first writeln returns the correct value. The second hand returns nothing!
I suggest some ideas?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Function Time and blank result
« Reply #10 on: February 03, 2010, 02:15:10 pm »
But what I say is that if it were a problem Lazzarus should recur in every application that I do. Instead solely in this one! If I create a new application that works, do not understand why. Not that there is some variable related to the project that contains the format for date and time and who may be affected that variable?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Function Time and blank result
« Reply #11 on: February 03, 2010, 02:25:48 pm »
I'm run-out of ideas... :(

Try to reinstall FPC and Lazarus.

Source code of your textual files you may cleanup if you make some simple console app to filter $FF, or copy it  to some text processor which can filter all unknown characters and then save it again. I do not remember which text processor I used.

Or rewrite by hands problematic line in source.

There is possibility that problem also caused something else...

What do you mean $ FF?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Function Time and blank result
« Reply #12 on: February 03, 2010, 02:37:32 pm »
what is the output of
writeln(LongTimeFormat.LongTimeFormat);

Maybe it get's reset somewhere?

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Function Time and blank result
« Reply #13 on: February 03, 2010, 11:14:26 pm »
Why does anyone think there might be a $FF character in OP's source code?

If it were, fpc would probably choke on it if it were not in a string ("fatal: illegal character"), and if it were in a string (i.e. between single quotes), how would that possibly affect the behaviour of the example code, since OP does not do any conversion of string into whatever?

What is the output of
Code: [Select]
var
  S: ShortString;
  T: TDateTime;
     
...
  writeln('TimeSeparator = ',TimeSeparator);
  writeln('LongTimeFormat = ',LongTimeFormat);
  TimeSeparator := ':';
  LongTimeFormat := 'hh:mm:ss';
  T := Time;
  DeCodeTime (T,Hh,MM,SS,MS);
  Writeln ('Present Time is : ',FormatDateTime('hh:mm:ss',EnCodeTime (HH,MM,SS,MS)));
  S := TimeToStr(T);
  writeln('Prova: "',S,'"');

Bart

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Function Time and blank result
« Reply #14 on: February 04, 2010, 07:51:19 am »
Why does anyone think there might be a $FF character in OP's source code?

If it were, fpc would probably choke on it if it were not in a string ("fatal: illegal character"), and if it were in a string (i.e. between single quotes), how would that possibly affect the behaviour of the example code, since OP does not do any conversion of string into whatever?

What is the output of
Code: [Select]
var
  S: ShortString;
  T: TDateTime;
      
...
  writeln('TimeSeparator = ',TimeSeparator);
  writeln('LongTimeFormat = ',LongTimeFormat);
  TimeSeparator := ':';
  LongTimeFormat := 'hh:mm:ss';
  T := Time;
  DeCodeTime (T,Hh,MM,SS,MS);
  Writeln ('Present Time is : ',FormatDateTime('hh:mm:ss',EnCodeTime (HH,MM,SS,MS)));
  S := TimeToStr(T);
  writeln('Prova: "',S,'"');

Bart

Result:
[WARNING] Out of OEM specific VK codes, changing to unassigned
[WARNING] Out of unassigned VK codes, assigning $FF
TimeSeparator = :
LongTimeFormat =
Present Time is : 07:49:49
Prova: "07:49:49"
hh:mm:ss


In this way is back to work. Thank you. But why he lost the time format?
« Last Edit: February 04, 2010, 08:38:42 am by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018