Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

Programming 1 (BI)
  ▸ exercises
  ▸ quick link

teaching assets


Félévek

* 2025/26/2
* archívum


Linkek

* kalendárium
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C#
* D lang.
* Java
* Nim
* Nim2
  + exercises
* XC=BASIC
* old
  ✦C++, ✦Clojure, ✦Scala


[ edit | logout ]
[ sandbox | passwd ]

The simplest way

Here 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 getAppFilename()." (source)

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
Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2026 June 04, 11:55