setdirectory(<string>)
load(<string>)
はファイル名とします。ディレクトリ名を含んでも構いません。 ファイル名が正しければ、ファイルに含まれる全情報が文字列として返されます。この演算子は tokenize
とともに、データを解析するのに有用です。データは setdirectory
で指定されたディレクトリから読まれます。LoadDemo.txt
には次のデータが入っているものとします。abc,gfdg;1,3,5.6,3.141;56,abc,xxx,yyy
x=load("LoadTest.txt"); y=tokenize(x,(";",",")); apply(y,println(#));
[abc,gfdg] [1,3,5.6,3.141] [56,abc,xxx,yyy]
import(<string>)
はファイル名とします。ディレクトリ名を含んでも構いません。ファイル名が正しければ、ファイルの内容は CindyScript のコードとして解析され、実行されます。こうして、あらかじめ定義された関数ライブラリを読み込むことができます。 import
演算子は CindyScript の "Initialization" スロットだけで運用するのがよいでしょう。そうでないと、動作のたびに読み込まれることになります。openfile(<string>)
println(<file>,<string>)
println(...)
と同様ですが、 <file>
で指定したファイルに書き出します。print(<file>,<string>)
print(...)
と同様ですが <file>
で指定したファイルに書き出します。closefile(<file>)
setdirectory("../../../../"); f=openfile("myFile"); println(f,"Here are some numbers"); forall(1..15,print(f,#+" "); println(f,""); closefile(f);
Here are some numbers 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
openurl(<string>)
javascript(<string>)
<string>
に書きます。スタンドアロンのアプリケーションでは何もしません。javascript("alert('Hi from Cinderella!!')");
openconnection(<string>,<int>)
print(<handle>,<string>)
println(<handle>,<string>)
print
と println
関数は、ファイルだけでなく openconnection
によって作られるネットワークへも書き出しを行ないます。flush(<handle>)
readln(<handle>)
closeconnection(<handle>)
x=openconnection("cermat.org",80); println(x,"GET /"); y=""; while(!isundefined(y),y=readln(x);println(y)); closeconnection(x);
Page last modified on Friday 13 of April, 2012 [11:51:18 UTC].
The original document is available at
http://doc.cinderella.de/tiki-index.php?page=File%20ManagementJ