pascal

Pascal Access Violation when calling a variable in a class

不羁的心 提交于 2019-12-13 00:18:22
问题 I have made some very simple code in Pascal that is getting me this error: Project BugFixing.exe raised exception class EAccessViolation with message 'Access violation at address 0040F1EE in module 'BugFixing.exe'. Write of address 00000004'. The program consists of 2 modules: BugFixing.dpr: program BugFixing; {$APPTYPE CONSOLE} uses SysUtils, uLinearProgrammingMainLogic in 'uLinearProgrammingMainLogic.pas', math; var MinOrMax : integer ; Question : TQuestion ; begin try Randomize ; MinOrMax

InnoSetup, How to load a custom text into RTFText

淺唱寂寞╮ 提交于 2019-12-12 23:07:49
问题 I'm trying to store the text of InfoBefore textfile into a variable and then load it into the RTFEditor with a custom font color and backcolor. When I try to load the text from the variable it says "Write-only property" I need a explicit example of how to do this two things together (Store the text in the var, load the text in the RTF with a custom color and backcolor) without complicating the things too much because I don't know Pascal. This is the code: const FontColor: AnsiString = 'cf0';

Bit functions in Think Pascal

蓝咒 提交于 2019-12-12 16:29:04
问题 I am converting an old program written on Mac Think Pascal to Pascal on Windows. Think Pascal has functions for bit manipulations, such as btst(n, i : longint) : boolean bitxor(i, j : longint) : longint bclr(n, i : longint) : longint bset(n, i : longint) : longint ...and others. If you know what these functions do, please help. I have found some related information, for example "Porting to GNU Pascal from traditional Macintosh Pascal compilers". This document has implementations of the bit

How to select XML tag based on value of its child tag in Inno Setup

浪子不回头ぞ 提交于 2019-12-12 09:21:33
问题 I'm trying to search for a text "LIBRA ESTERLINA" in a child element of XML element and retrieve values of others child elements. But my query yields nothing. My code is based on response from How to read multiple XML nodes? (Inno Setup) and response from XPath: How to select elements based on their value? function LoadValuesFromXMLMoneda(FileName: string): Boolean; var XMLNode: Variant; XMLNodeList: Variant; XMLDocument: Variant; Index: Integer; id, moneda, dollar, abr, singPlur, caracter :

How to make a Digital clock in delphi7?

霸气de小男生 提交于 2019-12-12 07:58:24
问题 I am pretty new to delphi , and would like to start with something easy . Could someone please show me an example how to make a Digital clock that will transfer the "time" ( hour , min , sec ) to a label ? Or something like that 回答1: Exercise 1 Drop a TLabel and a TButton on your form. Double-click the button, and write procedure TForm1.Button1Click(Sender: TObject); begin Label1.Caption := TimeToStr(Time); end; Exercise 2 To get the time to update automatically, add a TTimer to your form,

PASCAL string to array

▼魔方 西西 提交于 2019-12-12 04:33:08
问题 Pascal, How can i turn (read) a string of numbers like for example '21354561321535613' into digits and stock them in an array ? 回答1: You can easily turn a digit into an integer by subtracting the ordinal value of '0' . Do this in a loop and you have an integer for each digit: var S: string; A: array of Integer; I, Len: Integer; begin S := '21354561321535613'; Len := Length(S); { Reserve Len Integers. } SetLength(A, Len); { Convert each digit into an integer: } for I := 1 to Len do A[I - 1] :=

Errors when using Lazarus IDE on OS X

痴心易碎 提交于 2019-12-12 04:04:06
问题 I'm trying to use Lazarus for OS X to complete a PASCAL programming assignment, and for some reason, I keep getting the following debugger error. Debugger Error Ooops, the debugger entered the error state. Save your work now! Hit Stop, and hope the best, we're pulling the plug. Even though it tells me "Project successfully built :)" after compiling, it will always give me that debugger error. When I rescan the FPC source directory, I get another error as well, even though I installed the FPC

Object Pascal: Must all objects (classes) be freed?

房东的猫 提交于 2019-12-12 03:57:29
问题 Can I throw around class es without freeing them, or will my software start spouting leaks? For example can I do this Engine := TEngine.Create(TV); Then get rid of the reference without any problems, or must I call its Free method first? Or have a function that returns a TSomething and not having to free its reference later on? 回答1: The general rule is that if you create it, you should free it. The best way is in a try..finally if you're creating it in code: var Engine: TEngine; begin Engine

Multiplying LongInts. Expression of the form: Int64Var := LongIntVar * LongIntVar

老子叫甜甜 提交于 2019-12-12 03:55:48
问题 I always thought it was part of the design philosophy in Pascal, that it looked at both the right and left hand sides of an expression when deciding what format/precision to use for an operation. So that, unlike C where an expression like, Float_Var = 1/3 results in a value of 0.0 for Float_Var, Pascal always gets this stuff right. :) So I was kind of surprised when I went to multiply two LongInts (32 bit) to give an Int64 result and found I was getting anomalous results. I had to get all C

How to avoid violating the DRY principle when the boolean expression of a while loop is reassigned every loop pass?

喜欢而已 提交于 2019-12-12 03:49:34
问题 Both while MyFunction(1, 2, 3) > 0 do begin Temp := MyFunction(1, 2, 3); ShowMessage(IntToStr(Temp)); end; and Temp := MyFunction(1, 2, 3); while Temp > 0 do begin ShowMessage(IntToStr(Temp)); Temp := MyFunction(1, 2, 3); end; violate the DRY principle because there are two calls to MyFunction when only one is necessary. 回答1: Easy, function dotemp(a,b,c:integer;var value : integer):boolean; begin value:a*b+c; result:=value>0; end; begin while dotemp(a,b,c,temp) do begin Operateontemp(temp);