11/29/2022 0 Comments Free pascal kill processWriteln('Parameter count=',inttostr(paramcount)) writeln(' output : ', inttostr(output) ) Whereas writeln has facilities to convert an integer argument to a formatted string, the way you have used it is attempting to output a string, so you need to convert the integer output to a string. intvar := strtoint(paramstr(n)) Īssigns the value of the string to the integer variable intvar. The command-line data is supplied via paramstr(n) as a string. inttostr is another, converting from an integer to a string. strtoint is one such function, converting a string to an integer. To convert betwwen an integer such as 123 and the string of characters 1 2 3 you need to use a function. You need to understand the difference between a string and an integer. You provided 1Ĭalling it with two parameters displays C:\Temp\TestParams 2 2 You provided ', ParamCount) Ĭalling it without parameters (or only one) displays the following: C:\Temp>TestParams WriteLn('There are two parameters required. Here's a working example (pretty trivial, and all error checking omitted - you should, for instance, protect the code using StrToInt to handle errors if something is provided that won't convert to an integer). Each value received using ParamStr is a string value, and therefore has to be converted into the appropriate type before you can use it. Additional parameters are retrieved using the ordinal order in which they were passed, with ParamStr(1) being the first, and ParamStr(ParamCount) being the last. #Free pascal kill process full#ParamStr(0) always gives you the full name of the executing program (including the path). ParamStr allows you to access each of the parameters passed. ParamCount returns the number of parameters passed on the command line, so you should check it first to see if you've received enough information. As the other answer says, you use ParamCount and ParamStr to access command line parameters.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |