pascal

Inno Setup: Exec can't read string?

こ雲淡風輕ζ 提交于 2019-12-08 02:01:52
问题 I'm trying to put together a simple Inno Setup installer which looks for the previous version and removes it before proceeding. Everything is working fine until I get the following code: if Exec(UninstallString, '/SILENT', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then begin MsgBox('Previous version found and uninstalled successfully.', mbInformation, MB_OK); end else begin MsgBox('Please uninstall the previous version of this mod before continuing.', mbInformation, MB_OK); Result :=

Delphi Pascal - Using SetFilePointerEx and GetFileSizeEx, Getting Physical Media exact size when reading as a file

一个人想着一个人 提交于 2019-12-07 23:38:46
问题 I do not know how to use any API that is not in the RTL. I have been using SetFilePointer and GetFileSize to read a Physical Disk into a buffer and dump it to a file, something like this in a loop does the job for flash memory cards under 2GB: SetFilePointer(PD,0,nil,FILE_BEGIN); SetLength(Buffer,512); ReadFile(PD,Buffer[0],512,BytesReturned,nil); However GetFileSize has a limit at 2GB and so does SetFilePointer. I have absolutley no idea how to delcare an external API, I have looked at the

Sockets in Pascal

情到浓时终转凉″ 提交于 2019-12-07 18:08:29
问题 How do you use network sockets in Pascal? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ 回答1: Here's an example taken from http://www.bastisoft.de/programmierung/pascal/pasinet.html program daytime; { Simple client program } uses sockets, inetaux, myerror; const RemotePort : Word = 13; var Sock : LongInt; sAddr : TInetSockAddr; sin, sout : Text; Line : String; begin if ParamCount = 0 then GenError('Supply IP address as parameter.'); with sAddr do begin Family := af_inet; Port := htons

Decomposition of number into prime numbers

杀马特。学长 韩版系。学妹 提交于 2019-12-07 15:55:46
问题 I'm trying to create a pascal program for decomposition of prime numbers, i.e. 16 = 2*2*2*2 210 = 2*3*5*7 I should input a number and I should return the prime numbers decomposition. I don't understand the solution in mathematical sense, could someone explain me this algorithm or pseudo code, as long as I understand what I'm creating programming isn't really an issue. Thanks 回答1: A naive way of doing this is to: k = 2 N = 210 while N > 1: if N % k == 0: // if k evenly divides into N print k /

编程语言那些事儿

余生长醉 提交于 2019-12-07 06:43:36
前言:本文根据网上各方材料整理总结而成。本人过去几年使用过的编程语言包括:C、C++、C#、Java、Pascal、Python、JavaScript、PHP、Perl等,先整理一下各编程语言的渊源,成此文。今后有空再总结一下各语言在语法和应用层面的异同点。 编程语言五大家族 早期的编程语言分为:FORTRAN、 COBOL、 LISP、 BASIC、 和ALGOL 家族。这些语言为不同的社会群体而设计。 FORTRAN:为科学家和工程师设计的,他们在计算机上编程的目的是是为了解决问题。 COBOL: 为商业设计的,最好的体现在于让商人们可以利用电脑时代。 LISP: 为计算机科学研究设计的,最突出的体现在计算机基本原理研究.。 BASIC: 为初学者设计的。 ALGOL: 语言是有计算机程序员修改,演变成其他流行的语言,如C,Pascal和Java的一个庞大的家族。 上面提到的某些语言已经不像当初那么流行了。 首先是COBOL, 很不幸,它以面向商业人员的很好的可读性就是它的失败点。商业人员发现,他们可以雇佣程序员去管理他们的系统。程序员自然会偏向于为他们设计的语言,而不是他们的老板。所以随着时间推移,越来越多的商业功能都使用例如VB, C, C++ 和Java实现了。现在,只有很少一部分软件仍通过COBOL语言编写。 BASIC却有不同的命运。他是为入门人员设计的

GUI Only By Using FPC

我们两清 提交于 2019-12-07 06:28:45
问题 I want to know how I can develop GUI applications(32 Bits) without using Delphi language(Object Pascsl), only by using FPC with Lazarus installed(Pascal). Thanks. 回答1: Use a widget set directly. Look at e.g. the examples in packages/gtk2 for unix, or the windows win32api usage demo. (demo\win32 in the FPC win32 installation) But not using lazarus makes you lose platform independance, and a lot of ease. Looking how lazarus does it, is still a possibility. A second option is https://github.com

string to integer conversion in Pascal, How to do it?

笑着哭i 提交于 2019-12-07 05:15:31
问题 How to convert a number printed in a string into integer? Thank you. 回答1: The is procedure Val: procedure Val(S; var V; var Code: Integer); This procedure operate on decimal and real numbers. Parmeters: S char sequence; for proper conversion it has to contain ‘+’, ‘-‘, ‘,’, ’.’, ’0’..’9’. V The result of conversion. If result going to be an Integer then S can't contain ‘,’, ’.’. C Return the position of the character from S, that interrupt the conversion. Use cases: Var Value :Integer; Val(

PWP , Pascal-Web-Page , Pascal Web 开发脚本编译器开发笔记

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 04:01:08
多年以来,我们用惯了 Pascal 来开发各种类似的程序和软件,得心应手,无所不能。唯独在 Web 开发和敏捷开发上有明显的不足。 网上也有几个开源的,但是性能和功能总是不理想。于是一直有自己动手,从底层做起,重新开发的冲动。 构思画图了两天,利用两个周末的时间,基本框架成型,已经可以投入生产环境使用。未来将用3-6个月的时间,继续的优化和完善。 目标: 1. 参考 ASP 和 PHP 的优点,性能上要达到 php 5.6 的水平。 2. 以 Delphi7 做为参考语言,全面兼容。 3. 程序框架以 FAST-CGI 的接口提供,需要配合 Nginx 等 Web Server 使用。 4. 支持 Windows/linux , 32 位首选开发, 未来成熟后,添加64位支持。 5. 支持命令行运行 pas 脚本。 性能和功能以 node.js 为参照,后期将命名为 node.pas 或者 something else. 6. 脚本引擎支持解析执行, 也支持 JIT 编译。以字节码的方式执行。 大大提高性能。 参考了 paxCompiler. 7. 支持外部 DLL引入和使用。 可以通过挂接 DLL/SO 的模式,扩展脚本的功能。 8. 内核支持 DAO 数据库,消息队列, MEMCached, Json , XML , 字符串处理。 SQLite 等模块。 开发语言 以

TDownloadURL cannot download from HTTPS

不羁岁月 提交于 2019-12-07 02:13:33
问题 I've been trying to create (TFileStream) a PDF through the TDownloadURL class, but I'm really having troubles in obtaining the file/stream from the URL, specially if the URL a HTTPS. I'm not sure if I was clear, but I will post a snippet so it might help understanding: implementation var pdfStreamed: TDownloadUrl; var fileStream : TFileStream; procedure generateStream; begin pdfStreamed:= TDownLoadURL.Create(nil); with pdfStreamed do begin URL := 'https://farm9.staticflickr.com/8327

How do I Invoke a procedure when inside another procedure in Pascal

丶灬走出姿态 提交于 2019-12-07 01:52:42
问题 procedure questiontype; begin writeln ('Enter the type of question you would like...'); writeln ('1. Add'); writeln ('2. Multiply'); writeln ('3. Subtraction'); writeln ('4. Division'); readln (typeofquestion); case typeofquestion of 1: add; 2: multiply; 3: subraction; 4: division else writeln ('Choose again'); end; end; The add, multiply, subtraction and division are all procedures. If i put this in the main program, it will work fine, but when i make this as a procedure itself, i get the