チャンク表現のローカルとグローバルプロパティ
チャンク表現は、SenseTalkスクリプトでテキストデータを扱う強力な方法を提供します。ここで説明するローカルおよびグローバルプロパティを使用すると、チャンクへのアクセス方法を制御することができます。SenseTalkでチャンクを使用する方法の詳細については、チャンク表現を参照してください。
ローカルとグローバルのプロパティ値の設定または変更:
SenseTalkのコマンドSet
またはPut
を使用してグローバルプロパティの値を設定することができます。これらのプロパティのいずれかを参照するときは、通常の変数と区別するためにプロパティ名の前にthe
を使用する必要があります。
例:
set the searchrectangle to [1,2,2,3]
put 2 into the remoteworkinterval
以下のようにグローバルプロパティ内の特定の名前付きプロパティを追加または変更することができます:
set the namedColors.pink to color("RGB,1.0,0.5,0.5") -- namedColorsグローバルプロパティにpinkを追加し、そのRGBカラー値を定義します
set the listFormat's separator to " & " -- listFormatグローバルプロパティのseparatorプロパティを設定します
プロパティは、setoption
またはsetoptions
コマンドを使用して設定または更新することもできます。setoption
コマンドを使用すると、単一のプロパティを更新することができます。setoptions
を使用すると、複数のプロパティを一度に更新することができます。
例:
setoption searchrectangle, [1,2,2,3]
setoptions {searchrectangle: [1,2,2,3], scriptlogging: yes}
setoption
およびsetoptions
はグローバルおよびローカルプロパティの使用に特化しているため、これらのコマンドのコマンド構文でプロパティ名からthe
を省略します。
ローカルおよびグローバルプロパティの操作に関する詳細情報についてはmd ローカルとグローバルプロパティのSenseTalkを参照してください。
the wordDelimiter
ローカルプロパティ、the defaultWordDelimiter
グローバルプロパティ
,
値: 任意の文字または文字のリストで、コンテナ内の単語間のセパレータとして機能します
デフォルト:
the wordDelimiter
の場合:the defaultWordDelimiter
グローバルプロパティの現在の値the defaultWordDelimiter
の場合:スペース、タブ、リターン
動作: これらのプロパティは、コンテナ内の単語間のセパレータとして認識される文字のセットを指定します。これらの文字の任意の順序または組み合わせのシーケンスは、単語間に現れることができます。
the wordDelimiter
プロパティは各ハンドラーにローカルです。ハンドラーの値を設定すると、そのハンドラーから呼び出される他のハンドラーの値には影響しません。各ハンドラーが実行を開始すると、そのハンドラーのthe wordDelimiter
はthe defaultWordDelimiter
グローバルプロパティの値に初期設定されます。
例:
set the itemDelimiter to "|" // Changes the local item delimiter to pipe
例:
put "A man, a plan, a canal. Panama!" into palindrome
put word 4 of palindrome //Returns 'plan,'
set the wordDelimiter to ".,!?;:" & space & tab
put word 4 of palindrome //Returns 'plan'
set the wordDelimiter to ",."
put word 4 of palindrome //Returns ' Panama!'
例:
md
set the defaultWordDelimiter to " " // Changes the word delimiter to space across all handlers
例:
set LookupNumber to "102,311,421.000.631.521"
set the DefaultWordDelimiter to comma&period
set Row to the fifth word of LookupNumber
log Row // Displays '631'
単語チャンク式に直接デリミタを指定することもできます。これには、カスタムチャンクで説明されているようにdelimited by
句を含めます。
関連項目:
the lineDelimiter
the itemDelimiter
the wordQuotes
ローカルプロパティ、the defaultWordQuotes
グローバルプロパティ
値: 開始と終了の引用符デリミタの2つの値のリスト、または開始と終了のデリミタとして使用される単一の値。また、empty
またはNone
に設定して単語の引用を無効にするか、Standard
に設定してデフォルトの引用を復元することもできます。
デフォルト:
the wordQuotes
の場合:the defaultWordQuotes
グローバルプロパティの現在の値the defaultWordQuotes
の場合:直接の二重引用符
動作: これらのプロパティは、単語チャンクの中で引用された「単語」を識別するために使用される引用符の文字または文字を指定します。デフォルトでは、ダブルクォート文字で始まる任意の単語は、次のダブルクォート文字(the wordDelimiter
ローカルプロパティからの任意の包含された文字を含む)までのすべての文字を含みます。
the wordQuotes
プロパティは各ハンドラーにローカルです。ハンドラーの値を設定すると、そのハンドラーから呼び出される他のハンドラーの値には影響しません。各ハンドラーが実行を開始すると、そのハンドラーのthe wordQuotes
はthe defaultWordQuotes
グローバルプロパティの値に初期設定されます。
例:
set the wordQuotes to "*"
例:
set Introduction to "Welcome to *The Manor*"
log the third word of Introduction // Displays '*The
set the wordQuotes to "*"
log the third word of Introduction // Displays '*The Manor*'
例:
set the wordQuotes to empty -- Disable quoting
put "Hi, I'm [[my long name]]" into format
set the wordQuotes to ("[[","]]")
put word 3 of format -- [[my long name]]
set sentence to <<Jack said "Let's go see a movie.">>
put word 3 of sentence -- "Let's go see a movie."
set the wordQuotes to empty -- Disable quoting
put word 3 of sentence -- "Let's
例:
set the DefaultWordQuotes to none // Disables word quoting
例:
set Introduction to <<Welcome to "The Manor">>
put word 3 of Introduction // Displays '"The Manor"'
set the DefaultWordQuotes to none
set Introduction to <<Welcome to "The Manor">>
put word 3 of Introduction // Displays '"The'