pascal

How to count all the words in a textfile with multiple space characters

无人久伴 提交于 2021-02-17 04:40:48
问题 I am trying to write a procedure that counts all the words in a text file in Pascal. I want it to handle multiple space characters, but I have no idea how to do it. I tried adding a boolean function Space to determine whether a character is a space and then do while not eof(file) do begin read(file,char); words:=words+1; if Space(char) then while Space(char) do words:=words; but that doesnt work, and basically just sums up my(probably bad) idea about how the procedure should look like. Any

How to count all the words in a textfile with multiple space characters

青春壹個敷衍的年華 提交于 2021-02-17 04:40:36
问题 I am trying to write a procedure that counts all the words in a text file in Pascal. I want it to handle multiple space characters, but I have no idea how to do it. I tried adding a boolean function Space to determine whether a character is a space and then do while not eof(file) do begin read(file,char); words:=words+1; if Space(char) then while Space(char) do words:=words; but that doesnt work, and basically just sums up my(probably bad) idea about how the procedure should look like. Any

What does caret dot (^.) mean?

房东的猫 提交于 2021-02-07 14:40:41
问题 What does the below Pascal code mean? p^.rlink=q q^.llink=p 回答1: The pascal operator ^. is similar to operator -> in C and C++. It dereferences the pointer (in your case, p should be defined as var p: ^type ) and accesses a variable in the record, in this case, rlink and llink . 回答2: When caret (^) appears after a pointer variable it dereferences the pointer, that is, it returns the value stored at the memory address held by the pointer. So in your case I suppose that p is a pointer to a

What does caret dot (^.) mean?

穿精又带淫゛_ 提交于 2021-02-07 14:39:42
问题 What does the below Pascal code mean? p^.rlink=q q^.llink=p 回答1: The pascal operator ^. is similar to operator -> in C and C++. It dereferences the pointer (in your case, p should be defined as var p: ^type ) and accesses a variable in the record, in this case, rlink and llink . 回答2: When caret (^) appears after a pointer variable it dereferences the pointer, that is, it returns the value stored at the memory address held by the pointer. So in your case I suppose that p is a pointer to a

What does caret dot (^.) mean?

天大地大妈咪最大 提交于 2021-02-07 14:38:36
问题 What does the below Pascal code mean? p^.rlink=q q^.llink=p 回答1: The pascal operator ^. is similar to operator -> in C and C++. It dereferences the pointer (in your case, p should be defined as var p: ^type ) and accesses a variable in the record, in this case, rlink and llink . 回答2: When caret (^) appears after a pointer variable it dereferences the pointer, that is, it returns the value stored at the memory address held by the pointer. So in your case I suppose that p is a pointer to a

How to format a number in scientific notation

爱⌒轻易说出口 提交于 2021-01-27 17:01:48
问题 So basically I have this function which returns: 3.00000000000E000 function lang():extended; begin wynik := 0 ; counter := 1; temp :=1; input := 2; for i:= 1 to 4 do begin for k:= 1 to 4 do begin if i = k then counter := counter else temp := temp * ((input - a[k]) / (a[i] - a[k])); end; wynik := wynik + temp*f[i]; temp := 1; end; Result := wynik; end; But when I try to print it on the application screen using FloatToStr, I get only 3. procedure TFormCalculator.Button1Click(Sender: TObject);

How to format a number in scientific notation

时光总嘲笑我的痴心妄想 提交于 2021-01-27 17:01:31
问题 So basically I have this function which returns: 3.00000000000E000 function lang():extended; begin wynik := 0 ; counter := 1; temp :=1; input := 2; for i:= 1 to 4 do begin for k:= 1 to 4 do begin if i = k then counter := counter else temp := temp * ((input - a[k]) / (a[i] - a[k])); end; wynik := wynik + temp*f[i]; temp := 1; end; Result := wynik; end; But when I try to print it on the application screen using FloatToStr, I get only 3. procedure TFormCalculator.Button1Click(Sender: TObject);

Type Checking In Pascal

戏子无情 提交于 2021-01-27 04:32:41
问题 I'm just wondering how it's possible to do type checking in pascal? I have been searching for hours now but I haven't been able to find anything useful. Example: var number: Integer; begin write('Enter a number: '); read(number); if {How am I supposed to check if 'number' is an Integer here?} then writeln(number) else writeln('Invalid input') end. 回答1: You are actually hitting the I/O type checking. You can work around this by disabling it temporarily and then checking the result: {$I-} /

External Program running in different user desktop

烈酒焚心 提交于 2021-01-05 06:38:19
问题 I am trying to execute an external program under SYSTEM level and I applied this method (where I only changed the CreateProcessAsSystem('c:\windows\system32\cmd.exe'); to the path of the application I wanted to execute) and it works perfectly as expected only if there is one user logged into the pc. Eg. I have 2 users ( user1 and user2 ) and both users are logged in ( user1 first and then user2 ). Then, I run the program in user2 and my external program supposed to appear on user2 's desktop.

External Program running in different user desktop

对着背影说爱祢 提交于 2021-01-05 06:38:16
问题 I am trying to execute an external program under SYSTEM level and I applied this method (where I only changed the CreateProcessAsSystem('c:\windows\system32\cmd.exe'); to the path of the application I wanted to execute) and it works perfectly as expected only if there is one user logged into the pc. Eg. I have 2 users ( user1 and user2 ) and both users are logged in ( user1 first and then user2 ). Then, I run the program in user2 and my external program supposed to appear on user2 's desktop.