12: 2010-02-08 (月) 12:38:24 lina[4] [5] | 現: 2024-01-08 (月) 12:58:58 lina[4] [6] | ||
---|---|---|---|
Line 12: | Line 12: | ||
#include <guigui01.h> | #include <guigui01.h> | ||
+ | |||
/* これは関数の外で宣言するのが望ましい */ | /* これは関数の外で宣言するのが望ましい */ | ||
unsigned char cmdusage[] = { | unsigned char cmdusage[] = { | ||
Line 19: | Line 19: | ||
0x40 /* 最後のこれも決まり文句なので変更しない */ | 0x40 /* 最後のこれも決まり文句なので変更しない */ | ||
}; | }; | ||
+ | |||
この設定で表示されるUsage。 | この設定で表示されるUsage。 | ||
usage>ex0012.g01 n:# | usage>ex0012.g01 n:# | ||
Line 136: | Line 136: | ||
0x86, /* これは決まり文句なのでとりあえず変更しない */ | 0x86, /* これは決まり文句なのでとりあえず変更しない */ | ||
0x55, /* 引数名省略可能モード */ | 0x55, /* 引数名省略可能モード */ | ||
+ | |||
0x1c, 2, 'o','p','t', 0x0c, 9, 0x01, 'i', 'o', 'n', '-', 'f', 'i', 'l', 'e', | 0x1c, 2, 'o','p','t', 0x0c, 9, 0x01, 'i', 'o', 'n', '-', 'f', 'i', 'l', 'e', | ||
0x0c, 2, 'o','u','t', 0x0c, 9, 0x01, 'p', 'u', 't', '-', 'f', 'i', 'l', 'e', | 0x0c, 2, 'o','u','t', 0x0c, 9, 0x01, 'p', 'u', 't', '-', 'f', 'i', 'l', 'e', | ||
+ | |||
0x40 /* 最後のこれも決まり文句なので変更しない */ | 0x40 /* 最後のこれも決まり文句なので変更しない */ | ||
}; | }; | ||
Line 159: | Line 159: | ||
-int g01_getcmdlin_flag_s(int i) | -int g01_getcmdlin_flag_s(int i) | ||
-Void g01_getcmdlin_flag_o(i) | -Void g01_getcmdlin_flag_o(i) | ||
- | -Void g01_getcmdlin_int_s(i) | + | -Void g01_getcmdlin_int_s(i) COLOR(red){あっれえぇ?これはdevineなのに戻り値があるはず? 法則がわからん・・・} |
-int g01_getcmdlin_int_o(int i, int d) | -int g01_getcmdlin_int_o(int i, int d) | ||
-Void g01_getcmdlin_str_s0(i, n, p) | -Void g01_getcmdlin_str_s0(i, n, p) | ||
Line 192: | Line 192: | ||
0x86, /* これは決まり文句なのでとりあえず変更しない */ | 0x86, /* これは決まり文句なのでとりあえず変更しない */ | ||
0x55, /* 引数名省略可能モード */ | 0x55, /* 引数名省略可能モード */ | ||
+ | |||
0x1c, 2, 'o','p','t', 0x0c, 9, 0x01, 'i', 'o', 'n', '-', 'f', 'i', 'l', 'e', ←引数番号0 | 0x1c, 2, 'o','p','t', 0x0c, 9, 0x01, 'i', 'o', 'n', '-', 'f', 'i', 'l', 'e', ←引数番号0 | ||
0x0c, 2, 'o','u','t', 0x0c, 9, 0x01, 'p', 'u', 't', '-', 'f', 'i', 'l', 'e', ←引数番号1 | 0x0c, 2, 'o','u','t', 0x0c, 9, 0x01, 'p', 'u', 't', '-', 'f', 'i', 'l', 'e', ←引数番号1 | ||
+ | |||
0x40 /* 最後のこれも決まり文句なので変更しない */ | 0x40 /* 最後のこれも決まり文句なので変更しない */ | ||
}; | }; | ||
+ | |||
↓Usage表示(コマンドラインの設定)はこうなる。 | ↓Usage表示(コマンドラインの設定)はこうなる。 | ||
usage>test.g01 [opt:option-file] out:output-file | usage>test.g01 [opt:option-file] out:output-file | ||
Line 207: | Line 207: | ||
>hijk.exe test.g01 opt:hogehoge.txt out:ugougo.txt | >hijk.exe test.g01 opt:hogehoge.txt out:ugougo.txt | ||
i=1 ←0番目の引数が存在するぞ! | i=1 ←0番目の引数が存在するぞ! | ||
+ | |||
>hijk.exe test.g01 out:ugougo.txt | >hijk.exe test.g01 out:ugougo.txt | ||
i=0 ←0番目の引数は指定されてない(空)だぞ! | i=0 ←0番目の引数は指定されてない(空)だぞ! | ||
Line 288: | Line 288: | ||
int n; n = 16; ←取得する文字列の最大長(この場合は16バイト分) | int n; n = 16; ←取得する文字列の最大長(この場合は16バイト分) | ||
char s[16]; ←取得した引数(文字列)を格納する配列orポインタ | char s[16]; ←取得した引数(文字列)を格納する配列orポインタ | ||
+ | |||
g01_getcmdlin_str_s0(i, n, s) ←戻り値なし。引数がs[]に格納され、末尾に0が付く | g01_getcmdlin_str_s0(i, n, s) ←戻り値なし。引数がs[]に格納され、末尾に0が付く | ||
Line 317: | Line 317: | ||
g = g01_getcmdlin_int_o(0,100); // 0番目の引数を取得し、もしなかったら規定値として | g = g01_getcmdlin_int_o(0,100); // 0番目の引数を取得し、もしなかったら規定値として | ||
100を返す | 100を返す | ||
+ | |||
この流れで行くとstrタイプも・・・・ | この流れで行くとstrタイプも・・・・ | ||
*g = g01_getcmdlin_str_s0(0); // 0番目の文字型引数を取得し、gに渡す | *g = g01_getcmdlin_str_s0(0); // 0番目の文字型引数を取得し、gに渡す | ||
Line 330: | Line 330: | ||
#include <guigui01.h> | #include <guigui01.h> | ||
#include <stdio.h> | #include <stdio.h> | ||
+ | |||
unsigned char cmdusage[] = { | unsigned char cmdusage[] = { | ||
0x86, /* これは決まり文句なのでとりあえず変更しない */ | 0x86, /* これは決まり文句なのでとりあえず変更しない */ | ||
0x55, /* 通常モード(引数名省略不可) */ | 0x55, /* 通常モード(引数名省略不可) */ | ||
+ | |||
0x0c, 2, 'o','p','t', 0x3c, 9, 0x01, 'i', 'o', 'n', '-', 'f', 'i', 'l', 'e', | 0x0c, 2, 'o','p','t', 0x3c, 9, 0x01, 'i', 'o', 'n', '-', 'f', 'i', 'l', 'e', | ||
+ | |||
0x40 /* 最後のこれも決まり文句なので変更しない */ | 0x40 /* 最後のこれも決まり文句なので変更しない */ | ||
}; | }; | ||
+ | |||
void G01Main() | void G01Main() | ||
{ | { | ||
g01_setcmdlin(cmdusage); //コマンドライン定義 | g01_setcmdlin(cmdusage); //コマンドライン定義 | ||
+ | |||
char *buffer = g01_bss1a1; //お便利バッファ2MBを宣言 | char *buffer = g01_bss1a1; //お便利バッファ2MBを宣言 | ||
g01_getcmdlin_str_s0(0,100,buffer); //引数受け取り | g01_getcmdlin_str_s0(0,100,buffer); //引数受け取り | ||
+ | |||
g01_putstr0(buffer); | g01_putstr0(buffer); | ||
return; | return; | ||
Line 404: | Line 404: | ||
#include <guigui01.h> | #include <guigui01.h> | ||
#include <stdio.h> | #include <stdio.h> | ||
+ | |||
unsigned char cmdusage[] = { | unsigned char cmdusage[] = { | ||
0x86, /* これは決まり文句なのでとりあえず変更しない */ | 0x86, /* これは決まり文句なのでとりあえず変更しない */ | ||
0x55, /* 通常モード(引数名省略不可) */ | 0x55, /* 通常モード(引数名省略不可) */ | ||
+ | |||
0x0c, 2, 'o','p','t', 0x0c, 9, 0x01, 'i', 'o', 'n', '-', 'f', 'i', 'l', 'e', | 0x0c, 2, 'o','p','t', 0x0c, 9, 0x01, 'i', 'o', 'n', '-', 'f', 'i', 'l', 'e', | ||
+ | |||
0x40 /* 最後のこれも決まり文句なので変更しない */ | 0x40 /* 最後のこれも決まり文句なので変更しない */ | ||
}; | }; | ||
+ | |||
void G01Main() | void G01Main() | ||
{ | { | ||
g01_setcmdlin(cmdusage); //コマンドライン定義 | g01_setcmdlin(cmdusage); //コマンドライン定義 | ||
+ | |||
char *buffer = g01_bss1a1; //お便利バッファ2MBを宣言 | char *buffer = g01_bss1a1; //お便利バッファ2MBを宣言 | ||
g01_getcmdlin_fopen_s_0_4(0); //引数受け取り&ファイルオープン | g01_getcmdlin_fopen_s_0_4(0); //引数受け取り&ファイルオープン | ||
+ | |||
jg01_fread0_4(2 * 1024 * 1024, buffer); /* 最大2MB, 終端に0がつく */ | jg01_fread0_4(2 * 1024 * 1024, buffer); /* 最大2MB, 終端に0がつく */ | ||
g01_putstr0(buffer); | g01_putstr0(buffer); |
(This host) = http://osask.net