6.1.14:Specifying
a Range
範囲の指定
To
specify a portion larger than a single chunk, you specify
the beginning and end of the range. These are all valid
chunk expressions:
単一のチャンクより大きな部分を指定するには、チャンクの範囲の始まりと終わりを指定します。次の表現式はどれも正しいものです:
get char
1 to 3 of "ABCD" -- yields "ABC" キャラクタ「ABC」が得られます
get word 2 to -1 of myValue -- second word to last
word 幾つあるか判らないワードの二番目から最後までが得られます
put it into line 7 to 21 of myValue --
replaces 結果として7行目から21行目の内容がitで置き換えられます
The start and end of the range must be specified as the
same chunk type, and the beginning of the range must occur
earlier in the value than the end. The following are not
valid chunk expressions:
チャンク範囲の始まりと終わりは同一のチャンク形式でなければなりません。しかも、当然ながら、範囲の始まりを示す数値は終わりを示す数値よりも前にある(数値が小さい)ものでなければなりません。
char 3
to 1 of myValue -- won't work end cannot be greater than
start
この例では、開始である3が終了である1よりも数値が大きいのでエラーとなります
char -1 to -4 of myValue -- won't work 4th from last comes
before last
この例では、最後から四番目(ー4)は最後(ー1)よりも前にあるのでエラーになります
Important:
To use negative
numbers in a range, remember that numerically, -x comes
after -x+1. For example, -1 is greater than -2, and 4 is
greater than -7. The greater number must come
last
in order to create
a valid range.
重要:範囲指定に負数を使うときには、数の上ではーXはーX+1の後ろに来るということを留意してください。具体的には、ー1はー2より大きい数値であり、4はー7よりも大きい数値です。従って、誤りの内販に指定をする為には、常に大きな数値が範囲の後ろ側になるわけです。