2005/1/10
ORGの例
変数の値を表示
一番簡単な例です
cプログラム
#include "org.h"
ORG *org;
org=orgset(100,10000); // PDWを使う準備
orgput(org,"abcd","ABC",-1); // 変数ABCに値 abcdを入れる
orgpage(org,"orgfile.org"); // ファイルorgfile.orgを使って表示する
orgend(org); // ORGを使い終わる
orgファイル
<html>
<body>
#ABC#
</body>
</html>
結果
abcd
複数の繰り返し(繰り返し数固定)
繰り返して表示する例です、毎回の繰り返し回数は毎回同じ場合です。
cプログラム
#include "org.h"
ORG *org;
char dd[100];
int i,t;
org=orgset(100,10000);
for(i=0;i<6;i++){
for(t=0;t<3;t++){
sprintf(dd,"aaa%dbbb%d",i,t);
orgput(org,dd,"ABC",i,t,-1);
}
}
orgiput(org,3,"T",-1);
orgiput(org,6,"I",-1);
orgpage(org,"orgfile.org");
orgend(org);
orgファイル
<html>
<body>
#{I#
#{T#
#ABC.I.T#
#}#
#}#
</body>
</html>
結果 (スペースは無視)
aaa0bbb0 aaa0bbb1 aaa0bbb2
aaa1bbb0 aaa1bbb1 aaa1bbb2
aaa2bbb0 aaa2bbb1 aaa2bbb2
aaa3bbb0 aaa3bbb1 aaa3bbb2
aaa4bbb0 aaa4bbb1 aaa4bbb2
aaa5bbb0 aaa5bbb1 aaa5bbb2
複数の繰り返し(繰り返し数変動)
繰り返して表示する例です、繰り返しの回数は各回で違います。
cプログラム
#include "org.h"
ORG *org;
char dd[100];
static int n[]={3,2,1,2,2,3};
int i,t;
org=orgset(100,10000);
for(i=0;i<6;i++){
for(t=0;t<n[i];t++){
sprintf(dd,"aaa%dbbb%d",i,t);
orgput(org,dd,"ABC",i,t,-1);
}
orgiput(org,t,"T",i,-1);
}
orgiput(org,i,"I",-1);
orgpage(org,"orgfile.org");
orgend(org);
orgファイル
<html>
<body>
#{I#
#{T.I#
#ABC.I.T#
#}#
<br>
#}#
</body>
</html>
結果 (スペースは無視)
aaa0bbb0 aaa0bbb1 aaa0bbb2
aaa1bbb0 aaa1bbb1
aaa2bbb0
aaa3bbb0 aaa3bbb1
aaa4bbb0 aaa4bbb1
aaa5bbb0 aaa5bbb1 aaa5bbb2
外部変数の値を表示
ORGファイルに設定された文字列を表示します。
cプログラム
#include "org.h"
main(int argc,char *argv){
ORG *org;
org=orgset(100,10000);
orgkput(org,"abcd","ABC",-1); // 変数ABCに値 外部変数abcdの値を入れる
orgpage(org,argv[1]); // 外部から与えられたORGファイルを使って表示する
orgend(org);
}
orgファイル (aaa.org)
##abcd=祝日
<html>
<body>
#ABC#
</body>
</html>
結果
祝日
orgファイル (bbb.org)
##abcd=Holiday
<html>
<body>
#ABC#
</body>
</html>
結果
Holiday
トップ
ホーム