|
Oktatás * Programozás 1 * Szkriptnyelvek Teaching • Programming 1 (BI) Félévek Linkek * kalendárium |
Nim2 /
The simplest wayHere is the simplest way to work with command-line arguments. I found this solution after the previous two ways. import std/os proc commandLineParams(): seq[string] "This is a convenience proc which returns the command line parameters. This returns only the parameters. If you want to get the application executable filename, call import std/strformat # &"Hello {name}!" import std/os echo getAppFilename() echo getAppFilename().extractFilename() echo "---" let args = commandLineParams() for i, arg in args: echo &"args[{i}]: {arg}" Output: $ ./a.out aa bb 42 END /home/jabba/Dropbox/nim/Nim-2026/a66-command-line-arguments/simplest/a.out a.out --- args[0]: aa args[1]: bb args[2]: 42 args[3]: END |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |