turbo-pascal

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;

Convert double to Pascal 6-byte (48 bits) real format

旧城冷巷雨未停 提交于 2019-12-10 19:03:07
问题 I need to do some work on data contained in legacy files. For this purpose, I need to read and write Turbo Pascal's 6-byte (48 bit) floating point numbers, from PHP. The Turbo Pascal data type is commonly known as real48 (specs). I have the following php code to read the format: /** * Convert Turbo Pascal 48-bit (6 byte) real to a PHP float * @param binary 48-bit real (in binary) to convert * @return float number */ function real48ToDouble($real48) { $byteArray = array_values( unpack('C*',

What are WinTypes, WinProcs and SW_NORMAL?

隐身守侯 提交于 2019-12-02 03:47:45
In the program below, whare are WinTypes , WinProcs and what is the purpose of SW_NORMAL ? program ex; uses Wincrt,WinTypes, WinProcs; var ch:string; procedure exe (che:string); begin writeln('ecrire ch'); readln(che); if ch ='oui' then begin WinExec('cmd /k "C:\TPW\exercice\project\site.html"', SW_NORMAL); end; end; begin exe(ch); end. The code is in Turbo Pascal 1.5. Wintypes and winprocs are translated Windows 3.x headers that come with windows versions of Turbo Pascal and Delphi 1. In later Delphi versions these are aliased to the more "modern" (as in after 1995) win32 Windows unit. SW