Cancelling Scientific notation

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Cancelling Scientific notation

James Gibbens
Hallo FPC gurus,
I am VERY new to free pascal and I have a couple of problems. Can somebody please help?
1. If a, b are real numbers and I want to round a/b foo to 3 decimal places, the answer is displayed in Scientific notation. How do I turn that off?
2. Without using Object Pascal, how can I change the background colour, a very black BLACK, when the program runs? It is strenuous on my poor eyes.
Thank you so far. The rest of the problems can wait a couple of days.
James Gibbens.
 

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cancelling Scientific notation

Anthony Walter-3
1) Format('%.3f', [A / B]);
2) It depends on you GUI framework/library, but in Delphi and Lazarus it would be "Color := 0;"

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cancelling Scientific notation

Frank Peelo
In reply to this post by James Gibbens
On 25/01/2010 18:37, James Gibbens wrote:
> Hallo FPC gurus,
> I am VERY new to free pascal and I have a couple of problems. Can
> somebody please help?
> 1. If a, b are real numbers and I want to round a/b foo to 3 decimal
> places, the answer is displayed in Scientific notation. How do I turn
> that off?

Are you using Write and Writeln? For strings and integers, you can
specify the field width, e.g.
   x := 'Hello';
   Write(x:10);
will write the variable x using at least 10 characters, using spaces for
padding if necessary. For floating-point types you can also specify the
decimal places, e.g.
   y := 12.345;
   Writeln(y:0:2);
will write y using at least 0 characters, i.e. no padding at all, with 2
digits after the decimal point.

> 2. Without using Object Pascal, how can I change the background colour,
> a very black BLACK, when the program runs? It is strenuous on my poor eyes.

That I'm not so sure of. There used to be a crt unit, so add CRT to the
uses clause at the top of your program
uses foo, bar, CRT, whatever;
and then you could use
   textbackground(blue);
   textcolor(yellow);
and like that. I guess it's still supported.

Frank


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cancelling Scientific notation

James Gibbens
Good evening Frank,
Thank you very much for your answer. The Writeln(y:0:2); works beautifully.
The backgroundcolor is solved as far as the text goes, but the rest is still
black. What is the whole area cover by the program, the "screen" called?
I still need to down load the help files - so if I am stupid, please say so.
I am a retired MAths teacher and I want to make programs so that the
learners(?) [earlier we called them pupils / students] can PRACTISE the
Maths.

Thanks again
James

----- Original Message -----
From: "Frank Peelo" <[hidden email]>
To: "FPC-Pascal users discussions" <[hidden email]>
Sent: Monday, January 25, 2010 8:53 PM
Subject: Re: [fpc-pascal] Cancelling Scientific notation


> On 25/01/2010 18:37, James Gibbens wrote:
>> Hallo FPC gurus,
>> I am VERY new to free pascal and I have a couple of problems. Can
>> somebody please help?
>> 1. If a, b are real numbers and I want to round a/b foo to 3 decimal
>> places, the answer is displayed in Scientific notation. How do I turn
>> that off?
>
> Are you using Write and Writeln? For strings and integers, you can specify
> the field width, e.g.
>   x := 'Hello';
>   Write(x:10);
> will write the variable x using at least 10 characters, using spaces for
> padding if necessary. For floating-point types you can also specify the
> decimal places, e.g.
>   y := 12.345;
>   Writeln(y:0:2);
> will write y using at least 0 characters, i.e. no padding at all, with 2
> digits after the decimal point.
>
>> 2. Without using Object Pascal, how can I change the background colour, a
>> very black BLACK, when the program runs? It is strenuous on my poor eyes.
>
> That I'm not so sure of. There used to be a crt unit, so add CRT to the
> uses clause at the top of your program
> uses foo, bar, CRT, whatever;
> and then you could use
>   textbackground(blue);
>   textcolor(yellow);
> and like that. I guess it's still supported.
>
> Frank
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal 

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cancelling Scientific notation

Marco van de Voort
In our previous episode, James Gibbens said:
> Good evening Frank,
> Thank you very much for your answer. The Writeln(y:0:2); works beautifully.
> The backgroundcolor is solved as far as the text goes, but the rest is still
> black. What is the whole area cover by the program, the "screen" called?
> I still need to down load the help files - so if I am stupid, please say so.
> I am a retired MAths teacher and I want to make programs so that the
> learners(?) [earlier we called them pupils / students] can PRACTISE the
> Maths.

clrscr;

cleans the screen with the currently set fore- and background colors.
 
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cancelling Scientific notation

James Gibbens
Hallo all,
Thank you for all the answers I have received.
Some more stupid questions please:
1. How can I get fpc to use a comma (,) in stead of a period (.) as the
separator between whole number and fraction?
2. The window showing the program listing on the screen is rather mall. How
do I enlarge it to show more lines? I tried clicking and ragging but nothing
works.
3. I want to print the program listing. I click on Files, print and nothing
happens. The device is shaown as lst or prn. How do I fix that?

Thanks again.
James Gibbens





----- Original Message -----
From: "Marco van de Voort" <[hidden email]>
To: "FPC-Pascal users discussions" <[hidden email]>
Sent: Tuesday, January 26, 2010 11:23 PM
Subject: Re: [fpc-pascal] Cancelling Scientific notation


> In our previous episode, James Gibbens said:
>> Good evening Frank,
>> Thank you very much for your answer. The Writeln(y:0:2); works
>> beautifully.
>> The backgroundcolor is solved as far as the text goes, but the rest is
>> still
>> black. What is the whole area cover by the program, the "screen" called?
>> I still need to down load the help files - so if I am stupid, please say
>> so.
>> I am a retired MAths teacher and I want to make programs so that the
>> learners(?) [earlier we called them pupils / students] can PRACTISE the
>> Maths.
>
> clrscr;
>
> cleans the screen with the currently set fore- and background colors.
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal 

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal