No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
24 Posted Topics
Re: See comments in code: [CODE]program pro4(input, output); var tot, num, i: integer; ave: real; begin ave := tot / 4; { tot hasn't been initialized yet. Can't do this here. } for i := 1 to 4 do begin writeln(output, 'Enter integer'); readln(input, num + tot); { You can't perform … | |
Re: Very basic but should get you started... [CODE]program game; uses SysUtils; var UserInput: string; Number: Double; begin UserInput := ''; Write('Enter a word, character, or number: '); Readln(UserInput); if TryStrToFloat(UserInput, Number) then begin WriteLn('User entered a number.'); end else if Length(UserInput) = 1 then begin WriteLn('User entered a character.'); end … | |
Re: [CODE]program keepGoing; uses SysUtils; var Response: string; begin Response := 'Y'; repeat // Do your stuff here. write('Do you want to continue? '); readln(Response); until UpperCase(Response) = 'N'; end.[/CODE] | |
Re: [url]http://www.merlyn.demon.co.uk/pas-time.htm#RDT[/url] [url]http://www.geocities.com/prenaud167/Time.htm[/url] | |
Re: [CODE]program Timer; {$mode objfpc}{$H+} uses Classes, DateUtils, SysUtils { add your units here }; var TargetTime: TDateTime; begin; TargetTime := IncSecond(Now, 6); repeat until CompareTime(Now, TargetTime) >= 0; WriteLn('Six seconds have elapsed!'); end.[/CODE] | |
Re: Pass the variable "option" as a parameter to the ReadLn function. ReadLn(option); | |
Re: [url]http://lazarus-ccr.sourceforge.net/docs/rtl/system/random.html[/url] | |
Re: [CODE]program movies; {$mode objfpc}{$H+} uses Classes, SysUtils; type TMovie = record Name: string; RunTime: Integer; Year: Integer; end; TMovies = array[0..4] of TMovie; var I: Integer; MyMovies: TMovies; begin // Initialize the database MyMovies[0].Name := 'Rocky'; MyMovies[0].RunTime := 119; MyMovies[0].Year := 1976; MyMovies[1].Name := 'Titanic'; MyMovies[1].RunTime := 194; MyMovies[1].Year := … | |
Re: [url]http://www.gnu-pascal.org/gpc/CRT.html#CRT[/url] | |
Re: Hope this helps... [CODE]program a2; {$APPTYPE CONSOLE} uses SysUtils; const population = 10; type TpopRec = record age: integer; agerange: string end; Tperson = array[1..population] of TpopRec; {PRE: true POST: initialise the ages of all population} procedure initialise_age(var ftn: Tperson); var i: integer; begin for i := Low(ftn) to High(ftn) … | |
Re: [QUOTE=techied]How do you use sound and graphics in pascal?[/QUOTE] uses CRT, Graph, Video, etc. [url]http://www.freepascal.org/docs-html/rtl/index.html[/url] | |
Re: [QUOTE=mpx10]im still struggling to print an invoice that i have made in pascal to a usb port printer. any help please. i have tried using various inbuilt function but have had no luck probably because im coding it wrong. thanks in advance[/QUOTE] This works in Delphi 7 / WinXP: [CODE]program … | |
Re: [QUOTE=shmee]ok i think the program should look like this.. program pin; uses crt; var; pin : real; begin writeln ('enter pin here'); read (pin); for pin:= 1 to 9 do write ('*'); writeln (' Your pin is',pin); end. when i try to wok it doesn;t do what i want it … | |
Re: [CODE]program toy; var Option : Integer; procedure ShowMenu; begin writeln; writeln( '+------------------+' ); writeln( '| MENU |' ); writeln( '+------------------+' ); writeln( '| Options: |' ); writeln( '| 0=sleeps |' ); writeln( '| 1=laughs |' ); writeln( '| 2=cries |' ); writeln( '| 3=sings |' ); writeln( '| 4=exit |' … | |
Re: [CODE]highestavegrade := 0; for i:=1 to 10 do begin if avegradestudent[i] > highestavegrade then begin highestavegrade := avegradestudent[i]; end; end; for i:=1 to 10 do begin if avegradestudent[i] = highestavegrade then begin { writeln (*GOLD*, etc, etc } end; end; [/CODE] | |
Re: [QUOTE=lodacy]I will appreciate any help on the following. Please reply to [email]lotbook@telus.net[/email] as well. I am trying to program something that use huge integer matrices, say 100x1500. I can do it in Unix pascal, but the Unix machines are slow. I also have borland pascal 7.0, but all I could … | |
Re: You can use the [B]Copy [/B]function like this. [CODE]program TruncateString; {$APPTYPE CONSOLE} uses SysUtils; var Input : String; Output : String; begin writeln; write( 'Enter a string more than three characters long: ' ); readln( Input ); Output := Copy( Input, 1, 3 ); writeln; writeln( Output ); writeln; end.[/CODE] … | |
Re: Hi Jim, You should always use the "Dim VarName As Type" format in VBA. If you don't declare a type, the variables will default to the Variant type (which can hold any type of data but is not very efficient. Also, according to one book that I have (Excel 2000 … | |
Re: [CODE]program pizza; {$APPTYPE CONSOLE} uses SysUtils; const CaloriesPerSlice = 355; CaloriesBurnedPerHour = 240; var CaloriesBurnedPerMinute : Double; Hours : Double; SlicesOfPizzaEaten : Integer; TotalCalories : Integer; TotalMinutesToJog : Double; begin writeln; write( 'How many slices of pizza? ' ); read( SlicesOfPizzaEaten ); CaloriesBurnedPerMinute := CaloriesBurnedPerHour / 60.0; TotalCalories := SlicesOfPizzaEaten … | |
Re: [CODE]program dec2hex; {$APPTYPE CONSOLE} uses SysUtils; const BASE16 = 16; var HexValue : string; Remainder : Integer; Quotient : Integer; begin HexValue := ''; write( 'Enter an integer value: ' ); readln( Quotient ); while Quotient > 0 do begin Remainder := Quotient mod BASE16; case Remainder of 10: HexValue … | |
Re: Not exactly the formatting you wanted but should get you started... [CODE]program mtable; {$APPTYPE CONSOLE} uses SysUtils; var I : Integer; J : Integer; begin for I := 1 to 12 do begin for J := 1 to 12 do begin write( IntToStr( J * I ) + chr( 9 … | |
Re: [URL=http://www.freepascal.org/docs-html/fpchelp.html]Free Pascal Online Help[/URL] [URL=http://www.freepascal.org/docs-html/rtl/system/stringfunctions.html]String Handling Function (System Unit)[/URL] Have a look at the Pos function... | |
Re: [code] program FactorialCalculator; {$APPTYPE CONSOLE} uses SysUtils; var input : string; value : Integer; function calculate( num : integer ) : integer; begin if ( ( num = 0 ) or ( num = 1 ) ) then calculate := 1 else calculate := calculate( num - 1 ) * … | |
Re: 1. Is there a length function in Dev Pascal ? If so, what is it? If not, is there a way to achieve the length of a string? Dev Pascal uses either the Free Pascal compiler or the GNU Pascal compiler. [COLOR=Blue]Online documentation for FPC System unit: [I]length[/I]: Length returns … |
The End.