If both ! and $ are forbidden, the test should be an and, not an or. And instead of using ord(a[0]) to get the length of the string, you should use the provided length(a) function. You don't need to know that the first byte of the string hold its length,...
variables,event-handling,pascal,lazarus,procedures
The easiest way to do this is: Number the buttons using the Tag property in the Object Inspector (or in code when they're created) in order to easily tell them apart. (Or assign the value you want to be passed to your procedure/function when that button is clicked.) Create one...
As said @Marco van de Voort in comments the problem was in FPC running the .exe in its default directory instead of the directory it was saved in.
Trying to decipher the previous programmer's intent leads to another possibility.... It seems there was a fix applied for Delphi 2009 due to the changes in the string type. I'm sure you don't want to reinvent all the fixes that another programmer has already done. Looking at the code, Delphi...
It was a simple matter of removing the frmSequenciador prefix of the functions as Ken White stated. What I wanted to know is: if two functions are inside the same form unit (thx Jerry), do we need a prefix to call each other? It seems not. Thanks all!...
Only update primes when it's actually needed. Keep track of the number of entries you've updated, and only output that number of entries at the end: j := 0; for i := 0 to 999 do begin if candidates[i] <> 0 then begin primes[j] := i; Inc(j); end; end; for...
I think it will be something like that: static void Main(string[] args) { Console.Clear(); //unnecessary Console.Write("Variant="); int vers = Int32.Parse(Console.ReadLine()); Console.Write("Number of works="); int n = Int32.Parse(Console.ReadLine()); string X = vers.ToString(); string FileName = "Shed" + X + ".tab"; //or string FileName = "Shed" + vers.ToString() + ".tab"; //without unnecessary...
To make the example work, remove the line const CheckEOF: boolean=true; {My insertion} and insert CheckEOF:=true; before the Create; call in the main program. Then the program terminates when you press Ctrl-Z. Your code declares a new variable CheckEOF while you probably want to change CheckEOF of the crt unit....
I hope this will help you. type ch_array = array[char] of 1..26; var alphabet: ch_array; c: char; begin ... for c:= 'A' to 'Z' do alphabet[c] := ord(c); (* the ord() function returns the ordinal values *) More information can be checked at this link. http://www.tutorialspoint.com/pascal/pascal_arrays.htm Thanks...
This looks overly complex. If you just remove the counter, initialize P with the value -1 (instead of 0) and replace P := P + counter with P := P + 1, it should work.
sql,sql-server,delphi,pascal,firedac
Depending on the type of your application, include one of the following units into any one "uses" clause: FireDAC.VCLUI.Wait - for VCL applications; FireDAC.FMXUI.Wait - for FireMonkey applications; FireDAC.ConsoleUI.Wait - for console / non-visual applications. ...
Set your TP7 to target dos, not windows. Note that you might have an Windows only TP product (also known as TPW) COM files will still be out of your reach, but at least DOS exe files should run in dosbox. Keep in mind that COM files have a 64k...
Found this : type TFunction = function (arg1, arg2 : integer) : integer; function foo1(arg1, arg2 : integer) : integer; begin foo1 := arg1 + arg2; end; function foo2(func : TFunction, arg1 : integer) : integer; begin foo2 := func(arg1, 2) * 3; end; The call should be something like...
installation,inno-setup,pascal
Relocate the two calls to the ISSkin DLL from where they are now (above the second InitializeSetup) to just above the first InitializeSetup declaration. // Importing LoadSkin API from ISSkin.DLL procedure LoadSkin(lpszPath: String; lpszIniFileName: String); external '[email protected]:isskin.dll stdcall'; // Importing UnloadSkin API from ISSkin.DLL procedure UnloadSkin(); external '[email protected]:isskin.dll stdcall'; Change...
85 is 215, which hit's the integer's size limit causing an integer overflow. To avoid this, you could use a longint instead.
Use the {app} constant. The reference describes it as: The application directory, which the user selects on the Select Destination Location page of the wizard. For example: If you used {app}\MYPROG.EXE on an entry and the user selected "C:\MYPROG" as the application directory, Setup will translate it to "C:\MYPROG\MYPROG.EXE". Optionally...
The controls unit doesn't belong to fpc and can not be found in .../fpc/2.6.4/units/.... Instead it's part of lazarus. Search for the "lcl" directory and add it to your ppu path. ...
You've declared two variables of type Text, (df and f) in your var block. You open df with these lines: assign(df,filename); reset(df); You then read from f (which is not the file you opened above) in several lines, such as this one: Read (f, num); It's interesting to note that...
dos,reverse-engineering,pascal,ida,disassembler
As i can recognize, this function encode file content, by xoring with 0CDh constant, and then write it to buffer in memory.
You're not reading the izv variable. You should use readln() to read the user input.
In the sample, on line 13, I changed i:=2 to i:=1 and the code miraculously works. Why?!
set,time-complexity,pascal,fpc
According to this explanation, Pascal internally represents sets as bit strings. However, the article apparently does not refer to a specific implementation of Pascal. In this documentation, it is also stated that bitstrings are used for representation. More precisely, this documentation explicitly mentions 32 bytes for storage of a set.
boolean,pascal,long-integer,bubble-sort,insertion-sort
In Pascal, boolean operators and and or have higher precedence than the comparison operators >, =, etc. So in the expression: while j > 0 and A[j] > key do Given that and has higher precedence, Pascal sees this as: while (j > (0 and A[j])) > key do 0...
Checkboxes and Radio buttons created on runtime in Inno Setup do not scale their height automatically with DPI/font size. So you have to scale them programmatically. ... RadioButton.Left := WizardForm.TypesCombo.Left; RadioButton.Height := ScaleY(RadioButton.Height); RadioButton.Top := WizardForm.TypesCombo.Top + I * RadioButton.Height; ... Though note that using a non-default font-size for your...
pascal,freepascal,turbo-pascal
Wrap compound statements in a begin and end: procedure pay; begin loop:=loop+1; CASE loop OF 1: begin writeln('E-Mail: '); readln(mailO[1]); writeln('amount: '); readln(amount[1]); end; 2: writeln('simple statement'); 3: begin writeln('something else'); writeln('etc.'); end; end; end; ...
Use switch "/REGSERVERPERUSER" I use XE5, it work. Delphi write corresponding register keys...
pointers,pascal,dynamic-variables
You are right. Parens might be omitted. What pascal compiler do you use? Proper usage of New routine: New(arrp[variable]) ; parrp^[variable]^ := variable; P.S. Do you really need these pointer types here? P.P.S. Now I see an error: PIntegerArrayP = ^IntegerArrayP;...
installer,inno-setup,pascal,uninstaller,pascalscript
The possibility to check for the file existence beforehand was already mentioned. The user TLama mentioned that the code in the question is not regular pascal program code, but Inno Setup script code and and that my answer doesn't apply in this case. Because the following text could be of...
Sound does not work on Windows anymore. I made a patch that works on some systems, but they did not really care about it. -- Sound makes a sound forever / till NoSound is called. If you only want to make a sound for a certain duration you can use...
program Project1; {$ASSERTIONS ON} function getProb(aProbability: Integer): boolean; begin result := aProbability > (100 - random(100)); end; procedure miss; begin writeln('miss'); end; procedure hit; begin writeln('hit'); end; var i, success, probability, errorMarge: Integer; const combat: array[boolean] of procedure = (@miss, @hit); begin // show that getProb() is reliable errorMarge :=...
You can use the RegWriteBinaryValue function to write a binary value to registry. This function takes an ANSI string as parameter for passing data, so you can use it as long as the path that you are going to store does not contain Unicode chars.
It is not possible to do it unless you subclass that control. One alternative is to create a radio button with no caption and use a label together with it. In that way you can modify the colors of the label.
list,loops,linked-list,pascal,infinite
You are allocating a new g in the outer while not eof loop but you are linking it into the list multiple times in your while not eoln loop. You will need to allocate g in the inner loop.
image,processing,transformation,pascal
The bump thing alone is very complicated. Basically the simplest is indeed an (absolute) threshold for the difference px[1]-px[0]. (where px[1] is the pixelvalue of pixel n+1, and px[0] is shorthand for the pixelvalue of pixel n) In certain cases it is better to have a relative check (px[1]-px[0])/ (0.5*(px[1]+px[0]))>thresrelative...
Make sure that your files are not opened by any application. From the FreePascal documentation: Erase removes an unopened file from disk. The file should be assigned with Assign, but not opened with Reset or Rewrite. Program EraseDemo; Var MyFile: Text; begin Assign(MyFile, 'demo.txt'); Rewrite(MyFile); Writeln(MyFile, 'Lorem Ipsum dolor est');...
Wizard pages have two common properties for the top bar labels, Caption and Description. In your case you can update them e.g. when the page is just displayed, from the CurPageChanged event: [Setup] AppName=My Program AppVersion=1.5 DefaultDirName={pf}\My Program [Code] var MyPage: TWizardPage; procedure InitializeWizard; begin MyPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');...
delphi,devexpress,delphi-xe2,pascal
I found no easy way to format the strings to get the desired effect. The main reason for that is the simplicity of using the LeftTitle, CenterTitle or RightTitle 'boxes' - they only allow simple string text to be inserted. Nothing fancy allowed not to mention the True Type Font...
arrays,object,queue,pascal,freepascal
Init only calls the constructor. The initialization is done by calling new with the constructor as second argument, try for i:=0 to 9 do new(P[i], Queue.Init)); ...
c,compiler-construction,pascal,symbol
Here is an awsome free book: Compiler design in C
binary,decimal,pascal,freepascal
Check out this line: 5 div 2 = 4 It equals 2, not 4. You also have a typo here: 22 mod 2 = 1, x = "0" ...
As far as I know this is not possible in standard pascal, but I think you can do it like this: TYPE vektor = ARRAY[1..6] OF INTEGER; procedure former(var V:vektor; N:integer); var c,d,u:integer; ...
You need to fiddle with things a bit. There is no generic for enums so we get around it by casting to and from the enum using Byte, Word and Cardinal. program Project6; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, System.TypInfo; type TConversions<T> = record class function StringToEnumeration(x: String): T; static;...
delphi,md5,pascal,freepascal,turbo-pascal
The last step is wrong: a0 := a0 + A; b0 := b0 + B; c0 := c0 + C; d0 := d0 + D; it should change endianess: a0 := Swap32(a0 + A); b0 := Swap32(b0 + B); c0 := Swap32(c0 + C); d0 := Swap32(d0 + D); function...
algorithm,pascal,integer-division,largenumber
You will proceed from left to right, dividing the digits by two. Every time a digit is odd, you will propagate a carry (10) to the next digit. Example: divide 123 1 divided by 2 is 0, carry = 10 2 + 10 divided by 2 is 6, no carry...
You have to match every begin with an end at the same level, like if Condition then begin DoSomething; end else begin DoADifferentThing; end; You can shorten the number of lines used without affecting the placement, if you prefer. (The above might be easier when you're first getting used to...
Yes you can. But since you want to declare a type, you must type a valid type expresssion type menu = class private type menu_element = RECORD id: PtrUInt; desc: string; end; end; ...
n = n % 10 leaves n unchanged as soon as it's lower than 10, so it will usually never reach 0, hence the endless loop. The div operator in Pascal makes an integral division. Change n = n % 10 to n = Math.floor( n / 10 ); You...
Your program fails because you operate on copies of the array, rather than operating in-place. So consider the declaration of quicksort: Procedure quicksort(links, rechts: integer; localIntArray: iArray); The array is passed by value. You pass the array into the procedure, but any changes made to the array are never seen...
You can use a global object container for this purpose: TObjectList. When you create a new mail, add it to the container. In the OnSend eventhandler, you can remove the mail from the container. If you work like this, you can have multiple mails open at the same time: uses...
As 500 - Internal Server Error says, Pascal strings are 1-based. Your references to slot zero are returning garbage. If these are 256-byte strings you're getting the length code, I don't recall the memory layout of the pointer-based strings to know what you're getting in that case. You're also losing...
Just change this for(i = 0; i < pascal_string->size; i++) with for(i = 0; (i < 11) && (stringC[i] != 0) ; i++) since C strings are '\0' terminated, you have to loop untill you find the terminating '\0' or you are out of space. You can also compute the...
Obvious mistake: You are using print:=print+'x'+','; when you want print:=print+x+','; Mistakes in isMember: member:=false; you are not setting isMember, the returned value will be "random". You could remove member altogether and always use `isMember? if s.setsize=0 then Should be > 0. But it is not needed...
I think the infinite loop (writing hundreds of ones) is because you never read anything from the input so it is never at the end-of-line. Try putting a read(input,ch); in the loop.
In run-of-the-mill Pascal, arrays are value types, so in this procedure quickSort(arr: array of integer; left, right:integer); you are passing a copy of the array. Change to this procedure quickSort(var arr: array of integer; left, right:integer); and it should work better....
string,encoding,pascal,pascal-string
A Pascal-style string has one leading byte (length), followed by length bytes of character data. This means that Pascal-style strings can only encode strings of between 0 and 255 characters in length (assuming single-byte character encodings such as ASCII). As an aside, another popular string encoding is C-style strings which...
(i) call by value Whatever value is passed into p() is copied onto p()'s stack. That copy is used in the body of p(), so the original value is never changed. If a starts as 7 it will end as 7. (ii) call by reference A reference to the...
installer,inno-setup,pascal,pascalscript
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 using the WizardSelectedTasks function. This function returns a comma separated list of selected task names (or descriptions), and so it...
This equation can be solved by making a simple observation about + and | on a single bit value: When both values are 0, both operations produce 0, When the values are 1 and 0 or 0 and 1, both operations produce 1, When both values are 1, the results...
If you want to have exact decimals in Pascal, you have to use the currency type. program Zadanie2; var r : currency; begin r:=2.1; while r <> 4.3 do begin r:= r + 0.1; writeln(r:0:2); end; end. Now the output ends at 4.30. As you can notice, I also changed...
java,delphi,pascal,delphi-xe5,modbus
As you said, a Delphi Word is an unsigned 16 bit type. The Java char likewise is an unsigned 16 bit type. However, you mention Word in the question, but it doesn't appear in the code. Well, you use Word in ReadHoldRegisters but nowhere in Add_CRC16 is the Word type...
windows,installer,inno-setup,pascal,pascalscript
You are missing the exclusive flag: [Tasks] Name: hidden; Description: Hidden mode; GroupDescription: Installation Mode; Flags: exclusive Name: visible; Description: Visible mode; GroupDescription: Installation Mode; Flags: exclusive ...
delphi,math,numbers,pascal,divide
You need to calculate the remainder of zahl/i but your code calculates the remainder of i/zahl. So, instead of i mod zahl = 0 you need to test zahl mod i = 0 The function should be written like so: function FindeTeiler(Zahl: Integer): Integer; var i: Integer; begin Result :=...
Perhaps you have a typo in your code in dt := d - 1. The value of d seems to be constant within the loop, so dt would not change after the first successful check. I guess you might have wanted to decrement dt by using dt := dt -...
According to Lazarus forum (http://forum.lazarus.freepascal.org/index.php?topic=4936.0): Runtime Error 5 means Access denied. The file maybe readonly and you use the wrong (default) filemode, or you try to re-open the file with a new filehandle without having closed it before (somewhere in the while and repeat loops possibly you assignfile more then...
You are assuming that the second if is only executed when the first one fails, but nothing in your code indicates that is what should happen.
You may achieve your goal with the following algorithm: Create temporary file; Write your new data to this temporary file; Read all data from target file and append them to temporary file; Rename temporary file to target one; ...
how does TVector3i = array [0..2] of longint; convert? There is no direct equivalent. TVector3i is an alias for a static array. C# does not have similar aliasing for arrays. The best you can do is declare a struct that contains an int[] array inside of it, and provides...
The simplest way is to find the last path delimiter character and trim the source string. BTW there are some alternative: program Project1; uses sysutils; var sExe: string; sParent: string; sParentProper: string; begin sExe := ExtractFilePath(ParamStr(0)); // Get executable directory Writeln(sExe); sParent := IncludeTrailingPathDelimiter(sExe) + '..' + PathDelim; // Make...
Notwithstanding my comment above, here is a general helper. Your encryption is essentially designed to produce an anagram of the original and you use string concatenation which ties you to doing things in a certain order. If you rearranged your code a bit like this SetLength( Temp1, Length( Origin ));...
if-statement,while-loop,pascal
Yes, it's like while boolean and boolean do ... if ...; after do there must be only one command, because if you want to loop more lines then you can try while ... do begin ... end.
Here is how to start with Pascal: program qbsession; uses fphttpclient,sysutils; var HTTP: TFPHTTPClient; var qbresponse: String; const applicationId: String = '92'; authKey: String = 'wJHdOcQSxXQGWx5'; authSecret: String = 'BTFsj7Rtt27DAmT'; var randomValue: Integer; timestamp: Int64; body: String; signature: String; begin Randomize; randomValue := Random(5000); timestamp := Trunc((Now - EncodeDate(1970, 1...
You need to change the ; after your final end to a period (dot). (While you're at it, fix your indentation style to make the program flow clear.) program val; uses crt; var UI:string; x:integer; error:integer; begin repeat readln(UI); val(UI,x,error); until error = 0 ; writeln(UI); { I added a...
If I'm interpreting what you're trying to do correctly, this should work: const stateColor : array[TOC_StepState] of array[TOC_StepState] of TColor = ((clRed,clRed,clRed), (clYellow,clYellow,clYellow), (clGreen,clGreen,clGreen)); or const stateColor : array[0..2] of array[TOC_StepState] of TColor = ((clRed,clRed,clRed), (clYellow,clYellow,clYellow), (clGreen,clGreen,clGreen)); This syntax would also work (but I find it somewhat less readable -...
delphi,generics,pascal,delphi-xe6
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(Double) then Writeln('Double') else Writeln(PTypeInfo(TypeInfo(T))^.Name); end; procedure Main; begin TTest.Foo<string>; TTest.Foo<Double>; TTest.Foo<Single>; end; ...
The problem is the WPO is trying to extract symbols from your executable using NM. NM is not available for Windows. The good news is, Windows has DumpBin instead. I think you can use this directly in place of NM....
The compiler bit is easy, a Turbo compatible compiler is available from http://www.freepascal.org, but it is better to use it with an IDE like Lazarus http://lazarus.freepascal.org Lazarus is quite close to Delphi in philosophy, and pretty much Open Source's best kept secret. As for tutorials, that is a bit of...
windows,installer,inno-setup,pascal,pascalscript
You can use the code shown in the Uninstallable directive documentation: [Setup] ... Uninstallable=not IsTaskSelected('hidden') [Tasks] Name: hidden; Description: Hidden mode; GroupDescription: Installation Mode Name: visible; Description: Visible mode; GroupDescription: Installation Mode Optionally, if you'd need more complex statements written in reusable function, or access some of the scripting code...
geometry,computer-vision,delphi-7,pascal,feature-detection
If your rectangles are well defined as pictures show, then you can use Hough transform to determine parameters of lines (rectangle edges) and identify rectangle position and orientation.
The block of code that swaps, also needs to increment l and decrement r once the swap is complete: if (l <= r) then begin temp := iArray[l]; iArray[l] := iArray[r]; iArray[r] := temp; inc(l); // <-- this was missing dec(r); // <-- as was this end; The complete program,...
I won't attempt Pascal, but here is pseudocode for a solution that prints things in the order that you want. procedure print_partition(partition); print "(" print partition.join("+") print ") " procedure finish_and_print_all_partitions(partition, i, n): for j in (i..(n/2)): partition.append(j) finish_and_print_all_partitions(partition, j, n-j) partition.pop() partition.append(n) print_partition(partition) partition.pop() procedure print_all_partitions(n): finish_and_print_all_partitions([], 1, n)...