version0.7.10

This commit is contained in:
Andreas Rumpf 2009-06-08 08:13:09 +02:00
commit 36818817bd
14 changed files with 1011 additions and 0 deletions

9
examples/keyval.nim Normal file
View file

@ -0,0 +1,9 @@
# Filter key=value pairs from "myfile.txt"
import regexprs
for x in lines("myfile.txt"):
if x =~ r"(\w+)=(.*)":
echo "Key: ", matches[1],
" Value: ", matches[2]

15
examples/luaex.nim Normal file
View file

@ -0,0 +1,15 @@
# Embedds Lua into a Nimrod application
import
lua, lualib, lauxlib
const
code = """
print 'hi'
"""
var L = luaL_newstate()
luaL_openlibs(L)
discard luaL_loadbuffer(L, code, code.len, "line")
discard lua_pcall(L, 0, 0, 0)

6
examples/maximum.nim Normal file
View file

@ -0,0 +1,6 @@
# Test high level features
import strutils
echo "Give a list of numbers (separated by spaces): "
stdin.readLine.splitSeq.each(parseInt).max.`$`.echo(" is the maximum!")

11
examples/myfile.txt Normal file
View file

@ -0,0 +1,11 @@
kladsfa
asdflksadlfasf
adsfljksadfl
key=/usr/bin/value
key2=/ha/ha

12
examples/pythonex.nim Normal file
View file

@ -0,0 +1,12 @@
# Example to embed Python into your application
import python
# IMPORTANT: Python on Windows does not like CR characters, so
# we use only \L here.
Py_Initialize()
discard PyRun_SimpleString("from time import time,ctime\L" &
"print 'Today is',ctime(time())\L")
Py_Finalize()

25
examples/tclex.nim Normal file
View file

@ -0,0 +1,25 @@
# Example to embed TCL in Nimrod
import tcl, os
const
myScript = """puts "Hello, World - In quotes" """
myScript2 = """
package require Tk
pack [entry .e -textvar e -width 50]
bind .e <Return> {
set e [regsub { *=.*} $e ""] ;# remove evaluation (Chris)
catch {expr [string map {/ *1./} $e]} res
append e " = $res"
}
"""
Tcl_FindExecutable(getApplicationFilename())
var interp = Tcl_CreateInterp()
if interp == nil: quit("cannot create TCL interpreter")
if Tcl_Init(interp) != TCL_OK:
quit("cannot init interpreter")
if Tcl_Eval(interp, myScript) != TCL_OK:
quit("cannot execute script.tcl")