freepascal

安装 CodeTyphon

坚强是说给别人听的谎言 提交于 2021-02-07 11:51:47
一直想找个开源的可以商用的 Delphi 的替代品,能跨平台了最好。开始时试过 Lazarus ,和 D7 还真是挺像的,不过用惯了 XE ,还是想找个习惯相似的IDE,扒拉下论坛后发现了 CodeTyphon ,就想着试一下。 下载 下载就不多说了,网上很容易找到,而且官方 wiki 写得也很好,英文好的可以直接看,像我这样的英语渣渣,还是有必要慢慢去啃的。 CodeTyphon 下载后只有一个 CodeTyphonIns.zip 的压缩包,无论是 Windows 、 Linux 还是 MacOS ,安装包都是它,因为不管在哪个平台上安装,都是要编译的。 安装 解压 CodeTyphonIns.zip 得到 CodeTyphonIns 在 Windows 平台,以管理员方式运行 install.bat ;在类 unix 平台,先 cd CodeTyphonIns ,再 sudo ./install.sh 出现以下界面,输入 0 ==================================================== CodeTyphon Studio Version 7.30 (GEN 7) Installation for Linux-Solaris-Openindiana-MacOS FreeBSD-NetBSD-OpenBSD-DragonFly =====

Why i can use function name in pascal as variable name without definition?

冷暖自知 提交于 2021-01-28 18:50:20
问题 I was wondered about very strange behaviour in free pascal functions, described in docs. It is said, that following code will be compiled/executed successfully: function Test : integer; begin Test := 2; end; begin WriteLn(Test()); end. But if i use function name Test in the right side of equation, it will perform recursive loop. So, pascal functions, from one side, define variable with their name Test and type of function return value integer . From other side, you can still call function

How can I find the number of words in a given string?

瘦欲@ 提交于 2020-12-15 05:39:06
问题 I'm trying to find the number of words in a given string in Pascal? This is my starter coede: Program P1; var s:string; i,k:integer; begin write('Enter a string: '); readln(s); k:=0; for i:=1 to length(s) do begin if(s[i] = ' ') then k:=k+1; end; write('Number of words ', k); end. 回答1: You may implement the program as finite-state machine with two states ("inside word" and "word separator"): Program P1; type TState = (INSIDE_WORD, WORD_SEPARATOR); var s:string; i,k:integer; state: TState;

OSX app crashing: code signature invalid

三世轮回 提交于 2020-03-18 07:00:33
问题 I have an OSX app that I distribute outside the AppStore. Therefor I sign it with the according certificate (Developer ID Application Certificate). The app itself is written in Freepascal (Lazarus) and has a dependency lib, written in C++, which I also sign. I also change the path of the lib to be relative to the app by using install_name_tool and prefixing the path with @loader_path. Works like a charm for me locally. The app (as reported to me) works OK on OSX 10.11.6, but crashes on OSX 10

Array as an argument of a function

倾然丶 夕夏残阳落幕 提交于 2020-01-15 04:55:10
问题 I have 2 2-dimensional arrays and a function. I would like that function to take the array as an argument. I tried code like this: var array1:array[1..10,1..10] of integer; array2:array[1..20,1..10] of integer; function name(var my_array:array of array of integer, n:integer); function name(var my_array:array[1..n,1..10] of integer;const n:integer); But I got errors while trying to compile the code. Any tips? If you would like me to paste error codes for each version please leave a comment

System command executes but is immediately backgrounded

末鹿安然 提交于 2020-01-06 03:32:05
问题 I'm attempting to use the TProcess unit to execute ssh to connect to one of my servers and provide me with the shell. It's a rewrite of one I had in Ruby as the execution time for Ruby is very slow. When I run my Process.Execute function, I am presented with the shell but it is immediately backgrounded. Running pgrep ssh reveals that it is running but I have no access to it whatsoever, using fg does not bring it back. The code is as follows for this segment: if HasOption('c', 'connect') then

Lazarus & Free Pascal - How to recursively copy a source directory of files to another directory?

我们两清 提交于 2020-01-01 19:26:14
问题 I need to add some functionality to my Lazarus & Free Pascal GUI program - I need it to also copy files from a users chosen dir to another dir. I have a "Choose Source" TSelectDirectoryDialog button onclick event for the source directory and a "Choose Destination" TSelectDirectoryDialog button onclick event for the destination dir. I have a 3rd button to do the copying from Source to Destination. So far, I have found CopyFile that copies the files and the original date attributes, but it

How to use Pascal string in equation

☆樱花仙子☆ 提交于 2019-12-29 08:28:13
问题 I have a little problem. I have written a program which asks for user for a code which contains 11 digits. I defined it as string but now I would like to use every digit from this code individually and make an equation. for example if code is 37605030299 i need to do equation: (1*3 + 2*7 + 3*6 + 4*0 + 5*5 + 6*0 + 7*3 + 8*0 + 9*2 + 1*9) / 11 and find out what's the MOD. This is a calculation for an ISBN check digit. 回答1: Use a loop instead. (I'm only showing the total value and check digit

How to encode file of any type into base64 string and then decode it into file again using Lazarus/Delphi?

℡╲_俬逩灬. 提交于 2019-12-29 08:19:11
问题 Can you tell me how can I do that? Is there any Freepascal unit that can do this for me? I need that so my program can store binary data in it's XML-based fileformat. 回答1: Use the base64 unit and its two classes, TBase64EncodingStream and TBase64DecodingStream . Here is a simple example: program demo; uses Classes, base64; var DecodedStream: TStringStream; EncodedStream: TStringStream; Encoder: TBase64EncodingStream; Output: string; begin DecodedStream := TStringStream.Create('Hello World!');