Fix cross_calculator example
This commit is contained in:
parent
512db9aea6
commit
6244cc2e4f
4 changed files with 7 additions and 7 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
# Nimrod configuration file.
|
# Nimrod configuration file.
|
||||||
# The file is used only to add the path of the backend to the compiler options.
|
# The file is used only to add the path of the backend to the compiler options.
|
||||||
|
|
||||||
path="../nimrod_backend"
|
path="../nim_backend"
|
||||||
|
|
@ -21,7 +21,7 @@ type
|
||||||
cmdParams, # Two valid parameters were provided
|
cmdParams, # Two valid parameters were provided
|
||||||
cmdInteractive # No parameters were provided, run interactive mode
|
cmdInteractive # No parameters were provided, run interactive mode
|
||||||
|
|
||||||
TParamConfig = object of TObject
|
TParamConfig = object of RootObj
|
||||||
action: TCommand # store the type of operation
|
action: TCommand # store the type of operation
|
||||||
paramA, paramB: int # possibly store the valid parameters
|
paramA, paramB: int # possibly store the valid parameters
|
||||||
|
|
||||||
|
|
@ -63,7 +63,7 @@ proc parseCmdLine(): TParamConfig =
|
||||||
stdout.write USAGE
|
stdout.write USAGE
|
||||||
quit "Unexpected option: " & key, 2
|
quit "Unexpected option: " & key, 2
|
||||||
of cmdEnd: break
|
of cmdEnd: break
|
||||||
except EInvalidValue:
|
except ValueError:
|
||||||
stdout.write USAGE
|
stdout.write USAGE
|
||||||
quit "Invalid value " & val & " for parameter " & key, 3
|
quit "Invalid value " & val & " for parameter " & key, 3
|
||||||
|
|
||||||
|
|
@ -85,7 +85,7 @@ proc parseUserInput(question: string): int =
|
||||||
try:
|
try:
|
||||||
result = input.parseInt
|
result = input.parseInt
|
||||||
break
|
break
|
||||||
except EInvalidValue:
|
except ValueError:
|
||||||
if input.len < 1: quit "Blank line detected, quitting.", 0
|
if input.len < 1: quit "Blank line detected, quitting.", 0
|
||||||
echo "Sorry, `$1' doesn't seem to be a valid integer" % input
|
echo "Sorry, `$1' doesn't seem to be a valid integer" % input
|
||||||
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
In this directory you will find the nimrod commandline version of the
|
In this directory you will find the nim commandline version of the
|
||||||
cross-calculator sample.
|
cross-calculator sample.
|
||||||
|
|
||||||
The commandline interface can be used non interactively through switches, or
|
The commandline interface can be used non interactively through switches, or
|
||||||
interactively when running the command without parameters.
|
interactively when running the command without parameters.
|
||||||
|
|
||||||
Compilation is fairly easy despite having the source split in different
|
Compilation is fairly easy despite having the source split in different
|
||||||
directories. Thanks to the nimrod.cfg file, which adds the ../nimrod_backend
|
directories. Thanks to the nim.cfg file, which adds the ../nim_backend
|
||||||
directory as a search path, you can compile and run the example just fine from
|
directory as a search path, you can compile and run the example just fine from
|
||||||
the command line with 'nimrod c -r nimcalculator.nim'.
|
the command line with 'nim c -r nimcalculator.nim'.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue