Questions tagged [pascal]

Pascal is an imperative language from the Wirthian family created in 1969. It was widely used in engineering and teaching in the 1970s and 1980s. It lives on in compilers as Free Pascal and Delphi.

Pascal is an influential imperative and procedural programming language, designed in 1969 and published in 1970 by Niklaus Wirth as a small and efficient language. It was largely (but not exclusively) intended to teach students structured programming and data structuring.

Pascal is a descendant of , but it was implemented on a wide range of architectures, from PDP-11s, IBM PCs, to CDC Cyber and IBM System 370 mainframes. Pascal probably reached critical mass around the time Borland released Turbo Pascal in 1983.

Wirth later developed Modula-2 and Oberon and those languages share much of Pascal's design. Other derivatives include OOP-based Object Pascal (used in Delphi and Lazarus/Free Pascal).

Pascal is a purely procedural language and includes control statements with reserved words such as if, then, else, while, for, and so on. However, Pascal also has many data structuring facilities and other abstractions not included in ALGOL 60 like type definitions, records, pointers, enumerations, and sets.

External Resources

Free Pascal/Delphi Programming Books

2598 questions
13
votes
6 answers

Is there a good scripting Pascal-like language for Delphi?

I'm looking for a good free scripting engine for Delphi. I want to add scripting to an application so that I can write small test scripts. Specifically I need: Pascal-like syntax current (I looked at RemObjects Pascal Scripting but it is…
rossmcm
  • 5,493
  • 10
  • 55
  • 118
13
votes
3 answers

Pascal substr equivalent

I was looking for a Pascal equivalent for (for example) the php's substr function, which works like this: $new_string = substr('abcdef', 1, 3); // returns 'bcd' I've already found it, but I always take excessively long to do so, so I'm posting the…
Michael Konečný
  • 1,696
  • 1
  • 16
  • 20
12
votes
3 answers

Delphi passing parameters by reference or by value/copy

Context 1 var text:String; text:='hello'; myFunc(text); Context2 function myFunc(mytext:String); var textcopy:String; begin textcopy:=mytext; end; myFunc on the Context2 was called from the Context1, the local variable mytext is pointing…
Vitim.us
  • 20,746
  • 15
  • 92
  • 109
12
votes
6 answers

Strings in a separate .pas file

This may not be the correct place for this question, if not feel free to move it. I tagged as Delphi/Pascal because it's what I am working in atm, but this could apply to all programming I guess. Anyway I am doing some code cleanup and thinking of…
James West
  • 771
  • 1
  • 14
  • 26
12
votes
1 answer

What is a Pascal-style string?

The Photoshop file format documentation mentions Pascal strings without explaining what they are. So, what are they, and how are they encoded?
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
12
votes
3 answers

How to remove warning: link.res contains output sections; did you forget -T?

I'm using fpc compiler and I want to remove this warning. I've read fpc's options but I can't find how to do that. Is this possible? it appear when I run command: fpc foo.pas out: Target OS: Linux for i386 Compiling foo.pas Linking p2…
Jack
  • 16,276
  • 55
  • 159
  • 284
12
votes
10 answers

How to assign a multiline string value without quoting each line?

Is there a way to assign a multiline string value in Delphi without having to quote each line? Edit (the specific problem): I have some SQL queries which I want to test outside Delphi. When copying the queries it is a bit of overhead to add and…
Tihauan
  • 2,780
  • 2
  • 26
  • 29
12
votes
22 answers

What is the fastest possible way to sort an array of 7 integers?

This is a part of a program that analyzes the odds of poker, specifically Texas Hold'em. I have a program I'm happy with, but it needs some small optimizations to be perfect. I use this type (among others, of course): type T7Cards =…
Svein Bringsli
  • 5,640
  • 7
  • 41
  • 73
12
votes
2 answers

How can I compute a difference between two strings?

I want to create a function in Delphi that computes different levels of two strings. If two strings are equal (ignoring case), then it should return 0, but if they are not equal, it should return the number of different characters. This function can…
MajidTaheri
  • 3,813
  • 6
  • 28
  • 46
12
votes
2 answers

Check if character is letter in Delphi (Unicode)

Are there pre-defined charsets in Delphi, to check if a character is a letter? In Cocoa I use something like if ([[NSCharacterSet whitespaceCharacterSet] characterIsMember:character]) I know I can do in Delphi if c in ['A'..'Z'] then but will…
Miguel E
  • 1,316
  • 2
  • 17
  • 39
11
votes
2 answers

Why delphi BoolToStr true is represented as -1

Delphi function BoolToStr converts boolean value to a string. The result is either true or false, or 'numeric', '-1' and '0' respectively. Why -1 and not 1?
Doege
  • 341
  • 4
  • 12
11
votes
6 answers

How to get a random number in pascal?

I want to get a random number in pascal from between a range. Basically something like this: r = random(100,200); The above code would then have a random number between 100 and 200. Any ideas? The built in pascal function only lets you get a number…
Ali
  • 261,656
  • 265
  • 575
  • 769
11
votes
4 answers

Cast Enumeration Value to Integer in Delphi

Is it possible to cast/convert an Enumeration Value to Integer in Delphi? If yes, then how?
Shaun Roselt
  • 1,650
  • 5
  • 18
  • 44
11
votes
2 answers

Why Pascal const arrays aren't actually constants?

Program ConstTest; Const constVar = 1; Begin constVar := 3; WriteLn(constVar); End. It's pretty obvious that the above code will not compile, because it's not right to change the value of a constant. However, following code will…
Aleksejs Popovs
  • 850
  • 2
  • 12
  • 18
11
votes
2 answers

Testing the type of a generic in delphi

I want some way to write a function in delphi like the following procedure Foo; begin if T = String then begin //Do something end; if T = Double then begin //Do something else end; end; ie: I want to be…
sav
  • 2,064
  • 5
  • 25
  • 45