pascal

Testing the type of a generic in delphi

懵懂的女人 提交于 2019-12-22 04:06:25
问题 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 回答1: TypeInfo should work: type TTest = class class procedure Foo<T>; end; class procedure

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

℡╲_俬逩灬. 提交于 2019-12-22 01:30:55
问题 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

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

心已入冬 提交于 2019-12-21 03:58:23
问题 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 = array[0..6] of integer; There are two things about this array that may be important when deciding how to sort it: Every item is a value from 0 to 51. No other values are possible. There are no duplicates. Never. With this information, what is the absolutely

Need code for Inverse Error Function

梦想与她 提交于 2019-12-21 02:30:36
问题 Does anyone know where I could find code for the "Inverse Error Function?" Freepascal/Delphi would be preferable but C/C++ would be fine too. The TMath/DMath library did not have it :( 回答1: Here's an implementation of erfinv() . Note that for it to work well, you also need a good implementation of erf() . function erfinv(const y: Double): Double; //rational approx coefficients const a: array [0..3] of Double = ( 0.886226899, -1.645349621, 0.914624893, -0.140543331); b: array [0..3] of Double

How to show/use the user selected app path {app} in InputDirPage in Inno Setup?

只愿长相守 提交于 2019-12-20 02:56:18
问题 I'm creating an Installer using Inno Setup. I have to take two paths from user. One for program executables and another for libs. The default app folder is {pf}/companyname/applicationname In the InitializeWizard I have created second page which takes the lib folder from the user. Is there any way to change the default lib folder to the user selected folder {app} ? I have tried WizardDirValue . It just gives the default {app} value and NOT the path which user selected in first page. [code]

Try and Catch In Pascal

孤街浪徒 提交于 2019-12-20 00:06:20
问题 I'm using Dev-Pas 1.9.2 and am trying to make sure the program doesn't crash when a symbol or a letter value is entered. I've googled and googled and can't find any resoruce on how to achieve this. Any help is greatly appreciated. Thanks! Here is the code I'm trying to manage the input: Function GetMenuChoice : Integer; Var OptionChosen : Integer; Begin Write('Please enter your choice: '); Readln(OptionChosen); If (OptionChosen < 1) Or ((OptionChosen > 4) And (OptionChosen <> 9)) Then Begin

Scale radio button list with font size

孤街醉人 提交于 2019-12-19 11:52:40
问题 When trying to apply a custom installation mask with radio buttons (I used code provided here) I see I am unable to use higher fonts as a little spacing should be needed between one radio button field and another one.To give you a visual example : As default font size are not so easy to be read I wonder if there is a way of adding extra spacing between one radio button field and the next one. 回答1: Checkboxes and Radio buttons created on runtime in Inno Setup do not scale their height

InnoSetup, change the Uninstallable property behavior at runtime?

我怕爱的太早我们不能终老 提交于 2019-12-19 10:47:22
问题 SCENARIO I have created an installer that will installs a Malware application for educative purposes, the installer contains these two tasks: [Tasks] Name: hidden; Description: Hidden mode; GroupDescription: Installation Mode Name: visible; Description: Visible mode; GroupDescription: Installation Mode This means, performs a hidden installation for the user (hidden dirs and files and make uninstallabe the installer), or a visible installation (normal dirs and files and Uninstallable=True).

Hanging else problem?

天涯浪子 提交于 2019-12-19 08:48:11
问题 What is the "hanging else" problem? (Is that the right name?) Following a C++ coding standard (forgot which one) I always use brackets (block) with control structures. So I don't normally have this problem (to which "if" does the last(?) else belong), but for understanding possible problems in foreign code it would be nice with a firm understanding of this problem. I remember reading about it in a book about Pascal many years ago, but I can't find that book. 回答1: Which if does the else belong

Inno Setup - Dynamic positioning of controls/checkboxes

北城以北 提交于 2019-12-19 05:04:15
问题 I have a bunch of checkboxes on a page, and all of those are conditionally visible, and the Top position is defined relative to the previous checkbox, e.g. CheckBox4.Top := CheckBox3.Top + CheckBox3.Height + 5; When at least one of the components is set to be invisible, the result looks like this: What I'd like the checkboxes to do, is to shift upwards, if the previous one is set to invisible. Prog3 should be right underneath Prog1 , or, if both Prog2 and Prog3 are hidden, Prog4 should be