pascal

Writing a Scheme interpreter with FPC: Recursive data structures

感情迁移 提交于 2019-12-05 03:15:57
问题 Essentially, this is a question about recursive data structures in Pascal (FPC). As I would like to implement a Scheme interpreter like it is shown in SICP chapter 4, this question may be relevant for Schemers as well. :) S-expressions shall be represented as tagged data. So far, I have constructed a variant record, which represents numbers and pairs. Hopefully the code is readable and self-explanatory: program scheme; type TTag = (ScmFixnum, ScmPair); PScmObject = ^TScmObject; TScmObject =

Testing the type of a generic in delphi

本秂侑毒 提交于 2019-12-05 02:09:21
I want some way to write a function in delphi like the following procedure Foo<T>; begin if T = String then begin //Do something end; if T = Double then begin //Do something else end; end; ie: I want to be able to do different things based on a generic type I've tried using TypeInfo in System but this seems to be suited to objects rather than generic types. I'm not even sure this is possible in pascal TypeInfo should work: type TTest = class class procedure Foo<T>; end; class procedure TTest.Foo<T>; begin if TypeInfo(T) = TypeInfo(string) then Writeln('string') else if TypeInfo(T) = TypeInfo

Make an installer with text that is formatted (Partially Bold) in Inno Setup?

て烟熏妆下的殇ゞ 提交于 2019-12-04 23:56:00
问题 Anyone saw GOG.com game installer? How to make welcome text string like there including Path and Need Size in a single Caption? Where part of is bolded. Here are examples of how changes String line breaking after modifying install path 回答1: You can use a TRichEditViewer setting the RFTText property and the UseRichEdit to True. Try this sample procedure CreateCustomPages; var Page : TWizardPage; rtfHelpText : TRichEditViewer; s: string; begin Page := CreateCustomPage(wpWelcome, 'Custom wizard

Do console apps run faster than GUI apps? [closed]

醉酒当歌 提交于 2019-12-04 23:05:31
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center . Closed 9 years ago . I am relatively new to world of programming. I have a few performance questions: Do console apps run faster than apps with a graphical user interface? Are languages like C and Pascal faster than object oriented languages like C++ and Delphi? I know language speed depends more on compiler than on language itself,

How to add a region drop-down in Inno Setup?

时光毁灭记忆、已成空白 提交于 2019-12-04 21:00:33
In the Inno script, I am using the language selection drop down. I am also storing the selected language to a file called "language.properties" using the below code. The installed application uses this "language.properties" file. procedure CurStepChanged(CurStep: TSetupStep); var S: string; begin if CurStep = ssPostInstall then begin S := Format('language=%s', [ActiveLanguage]); SaveStringToFile(ExpandConstant('{app}') + '\language.properties', S, False); end; end; Now apart from language selection, I need to add a region selection drop down. The values for the regions is custom, (like America

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

ε祈祈猫儿з 提交于 2019-12-04 20:07:08
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 : String; begin XMLDocument := CreateOleObject('Msxml2.DOMDocument.6.0'); try XMLDocument.async := False;

Delphi passing parameters by reference or by value/copy

99封情书 提交于 2019-12-04 19:35:26
问题 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 to a memory outside the Context2? or the mytext have have their own memory space inside the scope, and filled/copied with the same content of the text ? I'm probably missing something really basic, because I'm getting a access violation error. There's any way

What is the best way to generate Pythagorean triples?

社会主义新天地 提交于 2019-12-04 17:14:50
I have tried with that simple code when you just check all the combinations for a and b and then check if square root of c is an integer, but that code is really slow, then I have tried with Euclid's formula a = d*(n^2 - m^2) b = 2*n*m*d c = d*(n^2 + m^2) and I have written a code where you first find n with trunc(sqrt(max_value)) //this is in pascal and then you check every combination of 0 < m < n but I get duplicate results, like if n is 7, m is 5 and d is 1, and n is 6, m is 1 and d is 2 . In both cases you get 24, 70 and 74. So what is a good fast way to calculate the number of

InnoSetup, prevent installation if any task is selected

左心房为你撑大大i 提交于 2019-12-04 16:50:14
My inno script has two tasks: [Tasks] Name: client; Description: Install FTP client Name: server; Description: Install FTP server I would like to deny the installation in a non-intrusive way if any task is selected, for non.intrusive I mean for example enabling/disabling the "next" button when one of both tasks are checked, no advertising messagbe-box. I'm not sure if innosetup has a parameter or a "check" function to do this in a simple way How I could do it? There is no way to do what you want natively in Inno Setup. You will need to do it from code by yourself. You can cheat here a bit by

How can I access a delphi control from outside the form's unit?

岁酱吖の 提交于 2019-12-04 14:24:15
I'm trying to call the Enabled property of a Timer from a procedure defined like this: procedure Slide(Form: TForm; Show: Boolean); and not with a fixed form name (like: Form2.Timer... ) After putting the form's unit in the uses list, this works: Form2.Timer1.Enabled := True; but the following is not working: Form.Timer1.Enabled := True; (where Form is the form passed as parameter to the procedure. How to get access to the Timer component on my form? Thanks in advance. You cannot access the Timer from your procedure because your parameter is a TForm, and TForm does not have a Timer1 member.