pascal

Only specific numbers in edit box

女生的网名这么多〃 提交于 2019-12-29 09:58:10
问题 I would like that user could write only numbers from 1 to 49 in edit box. I know how to exclude letters and has possibility to put only numbers but I can't limit it to specific numbers (e.g from 1 to 49 - like in lottery game). I added KeyDown event to edit box and put this code: if not (KeyChar in ['1'..'9']) then begin ShowMessage('Invalid character'); KeyChar := #0; end; How can I modify it? 回答1: Following David's advice, a pattern I often use looks something like this : function

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

Nested constants of nested structured types are unsupported?

余生颓废 提交于 2019-12-29 07:46:10
问题 Despite of what Delphi reference says structured types can contain other structured types; a type can have unlimited levels of structuring with notable exception what structured typed constants cannot contain file-type values at any level I discovered what I cannot use record constant as an element of array constant of the same type. Testcase type MyRecord = record MyField: Integer end; const Typical: array[0..1] of MyRecord = ((MyField: 0), (MyField: 1)); { now I tried to achieve more

Inno Setup - Convert array of string to Unicode and back to ANSI

淺唱寂寞╮ 提交于 2019-12-29 01:29:10
问题 I'm loading a Korean CP51949 (EUC-KR) encoded ANSI file into an array of strings ( LoadStringsFromFile ). My system and the intended end user systems do not have CP51949 set as a legacy non-Unicode encoding. At the moment I have 2 problems with this: Unless I run the application with Locale Emulator (which is just annoying, since the setup itself is in English only), the Korean text is displayed as gibberish. Pos gives wrong results and StringChange fails completely unless I switch to String

C#编码规范

蹲街弑〆低调 提交于 2019-12-26 19:47:22
一 . 目标 1. 安全 代码完成所需的功能之余 , 不要 产生负作用 , 要稳定可靠 . 2. 易读 类 , 实例 , 成员变量 , 成员函数的命名一目了然 3. 美观 尽量统一项目组内人员的编程风格 , 保证一致性 , 统一性 . 二 . 具体注意事项 . ( 一 ) 命名 1. 命名原则 (1) 所有的函数 ( 变量 / 类 / 文件名 ) 应该代表其实际的作用 . 应该使用具有意义的单词或多个词组合 , 但不要使用人名 , 项目组名 . (2) 所有的函数 ( 变量 / 类名 ) 一律使用英文 . (3) 使用多个单词时不需要使用连线 ( 如下划线 ) (4) 多个词组合较长时 , 可以使用单词的缩写 . (5) 不得使用非常相近的名字来表示几个不同含义的函数 ( 变量 / 类 ). (6) 命名时请考虑名字的唯一性和含义的准确性 . (7) 命名采用三种格式 ,Pascal( 大小写 ),Camel( 大小写混合 ), 首字母全部大写格式如 :ID 2. 变量的命名 (1) 变量名一般由 " 前缀 + 类型修饰 + 代表变量含意的英文单词或单词缩写 " 等部分组成 . 如 : * 前缀 ( 以下划线分割 ): t_: 表示线程的全局变量 . 如 :t_nCount m_: 表示类成员变量 ( 包含类表态变量 ) 如 :m_dwFlags _ 局部变量以 ”_” 开头,如

Pascal comparison error

前提是你 提交于 2019-12-25 12:47:11
问题 I have a problem with my very simple Pascal code. (I just started to learn Pascal.) So it's about an age comparison code then rest can be seen through the code. program Test; uses crt; var age : real; Begin writeln('Enter your age: '); readln(age); if age>18 then if age<100 then Begin clrscr; textcolor(lightgreen); writeln('Access Granted'); end else if age<18 then Begin clrscr; textcolor(lightred); writeln('ACCESS DENIED'); writeln('Reason:You are way to young'); end else Begin clrscr;

EAccessviolation AV Error using variables in Private

南笙酒味 提交于 2019-12-25 07:00:33
问题 I'm tidying up some code I've been given, for some reason, if the variables are defined under 'Private' (where they need to be to constrain access within this unit). I get EAccessViolation error when writing to them. If I loosely define them under Var just before implementaion they can be accessed ok. I'm comparing my structure with other similar units, where the Private units work fine & cant spot any significant differences.. Any suggestions? Error MSG: Project --- raised exception class

How to interpret RS232C interface communication written using Pascal to C#

对着背影说爱祢 提交于 2019-12-25 04:42:38
问题 I've a sample pascal program, provided in a technical handbook of coin counter S350/360 machine, that enables communication between the machine and a computer using RS232C cable. I've came up with the following equivalent C# code and for some reason only the procedures that only need to write data to the serial port are executing and working successfully. I can only write data to the port but cannot read any data from it. I checked this using a Serial Sniffer and it turns out it only sniffs

How to create dynamically changing serial numbers using Inno Setup?

时光总嘲笑我的痴心妄想 提交于 2019-12-25 04:22:20
问题 I have a page that prompts for serial number for my application when it is installed. I created the setup file using Inno Setup. What I would like to do is this : to prevent more than one installation using one setup file, I need to dynamically change the serial number that i would have provided in the inno setup scripting file. (i.e) Say i have supplied 123 as the serial number to my software and sell it. The buyer, once he enters that serial number and installs it, I need to change the

How to convert machine code to assembly code?

有些话、适合烂在心里 提交于 2019-12-25 01:27:53
问题 Please suggest me How to convert machine code to assembly code? excluding intel reference manual and dos debugger method? 回答1: You can use any debugger, such as gdb, or any disassembler, such as IDA Pro Advanced. There also are opensource ones, such as Agner Fog's objtool. IDA Pro Advanced also has the Hexrays plugin, with which you can decompile code. 回答2: look at this thread : How might I convert Intel 80386 Machine Code to Assembly Language? 来源: https://stackoverflow.com/questions/5630926