pascal

SIGSEV in custom QuickSort implementation

陌路散爱 提交于 2019-12-11 03:22:01
问题 I slept over the answer to question Quicksort drama and wanted to recode it from scratch, implementing your tip with the call-by-reference var. And again: I cannot find any failure I made again. I compare the code to your program one by one and I cannot find the problem. The following code produces an Exception (External:SIGSEV at address 11602) during compilation/run program quicksort; var iArray : array[0..8] of integer; procedure fillArray(var iArray : array of integer); begin; iArray[0] :

How can I “touch” a file from within an InnoSetup script?

别来无恙 提交于 2019-12-11 02:39:22
问题 How can I "touch" a file, i.e. update its' last modified time to the current time, from within an InnoSetup (Pascal) script? 回答1: Here's the code snippet for the TouchFile function: [Code] function CreateFile( lpFileName : String; dwDesiredAccess : Cardinal; dwShareMode : Cardinal; lpSecurityAttributes : Cardinal; dwCreationDisposition : Cardinal; dwFlagsAndAttributes : Cardinal; hTemplateFile : Integer ): THandle; #ifdef UNICODE external 'CreateFileW@kernel32.dll stdcall'; #else external

Checking if character is newline

瘦欲@ 提交于 2019-12-10 18:30:54
问题 Hello i'v got simple program which is couting characters in given text until line is empty line only with new line var znaki: array['a'..'z'] of integer = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); napis: String; maly: String; dlugosc: Integer; znak: char; begin napis := 'a'; while napis[1] <> '#13#10'do begin readln(napis); maly:=LowerCase(napis); for dlugosc:=(length(maly)) downto 1 do begin znaki[maly[dlugosc]]:=znaki[maly[dlugosc]]+1; end; for znak:='a' to 'z' do writeln(znak,

Why does the compiler say “undeclared identifier” when I try to show form B from form A?

被刻印的时光 ゝ 提交于 2019-12-10 17:49:41
问题 Why this code is not working: procedure TFormNotification.Button3Click(Sender: TObject); begin FormB.Show; end; I'm getting Undeclared identifier error. 回答1: You probably have a global variable named FormB declared in the interface section of a unit named UnitB . But UnitA doesn't know anything about that unit or its contents. In particular, it doesn't know what the word FormB means — that identifier is undeclared. To tell UnitA about the things declared in UnitB , add UnitB to the uses

Why we cannot declare local const variables in inno-setup [Code]?

混江龙づ霸主 提交于 2019-12-10 14:53:29
问题 Do you know why when declaring local const vars , the script cannot compile? Sorry, I know very little pascal and cannot figure out why this is not working! This example (see function CircleArea ) shows that my syntax should be fine. http://www.tutorialspoint.com/pascal/pascal_quick_guide.htm This is what I am trying to do: //---placed within [Code] procedure MyLog(const _functionName, _msg: String); begin Log(_functionName + '(): ' + _msg); end; function MyExec(const _filename, _params, _dir

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

眉间皱痕 提交于 2019-12-10 13:52:51
问题 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 /usr/bin/ld: warning: link.res contains output sections; did you forget -T? 79 lines compiled, 0.1 sec 回答1: It's a bug in certain LD versions. Just ignore it for now, or see if your distro has an update for your LD. (package binutils) http://www.freepascal.org

True C static local variable replacement?

一曲冷凌霜 提交于 2019-12-10 13:29:00
问题 just trying to achieve similar functionality of C/C++ static local variables in ObjectPascal/Delphi. Let's have a following function in C: bool update_position(int x, int y) { static int dx = pow(-1.0, rand() % 2); static int dy = pow(-1.0, rand() % 2); if (x+dx < 0 || x+dx > 640) dx = -dx; ... move_object(x+dx, y+dy); ... } Equivalent ObjectPascal code using typed constants as a static variable replacement fails to compile: function UpdatePosition(x,y: Integer): Boolean; const dx: Integer =

Bootable and cross platform applications and using delphi or Pascal

徘徊边缘 提交于 2019-12-10 13:15:43
问题 Is it Possible to create bootable (Applications for MBR )application using Delphi or Pascal (I know we cant use vcl , RTL and other stuffs because they depend on OS), but can i use at least Readln and writeln. If it is true !!! Can we run the program under other OS. but i know that PE (windows) and ELF (Linux ) formats are different. but at least with some small modification can i do it. 回答1: It's worth saying that PE is a very diverse format than ELF. Not only a few bytes to modify... the

how to validate Edit to only numbers & only text in inno setup? [duplicate]

非 Y 不嫁゛ 提交于 2019-12-10 11:57:07
问题 This question already has answers here : Required a number in text box in Inno Setup (3 answers) Closed 2 years ago . Is there a way to limit the characters to numbers and lenght to 10 with no space and another edit for just ? its for a phone number, and name that needs to have no spaces, dont have an idea how to do it. Found a code that try some ways to implement but dont work here is what I found for dont allow letters. procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin

Are Pascal comments supposed to nest?

陌路散爱 提交于 2019-12-10 03:26:50
问题 I have a compiler homework question that wants me to draw a DFA for Pascal comments, but I have never (and probably never will) use Pascal. The question does not specify if we should use ANSI Pascal or Turbo Pascal, so I was going to do one for both. Some Google searches showed me that Turbo Pascal allows nested comments as long as the same delimiter is not used, so {(*comment*)} is ok and so is (*{comment}*) , but {{comment}} or (*(*comment*)*) are not ok. My question here is if a comment