ModList 関数
カテゴリー : テキスト処理計算結果のデータタイプ : テキスト
対応FileMakerバージョン :










作者 : 給前悟郎 株式会社ジェネコム
概要
改行区切りのテキストの中の値に対して接頭/接尾辞の追加、値自体の置換を行う。構文
ModList ( Lists; Keyword; Add; Mode; Cnt )
引数
引数名 | タイプ | 備考 | 例 |
---|---|---|---|
Lists | テキスト | あ¶ういう¶う¶え¶お¶ | |
Keyword | テキスト | う | |
Add | テキスト | 追加テキスト! | |
Mode | 数字 | 1,2,3のどれかをセット | 2 |
Cnt | 数字 | 固定で1をセットする | 1 |
例
ModList ( "あ¶ういう¶う¶え¶お¶" ; "う" ; "追加テキスト!" ; 2 ; 1 )
結果
あ
ういう
う追加テキスト!
え
お
ういう
う追加テキスト!
え
お
式
/*
名 称:ModList ( Lists; Keyword; Add; Mode; Cnt )
概 要:
改行区切りのテキストの中の値に対して接頭/接尾辞の追加、値自体の置換を行う関数。
第一引数Lists:改行区切りの文字列。最後の文字も改行で終わっている事。
第二引数Keywords:キーワード。キーワード中に改行は含まない事。
第三引数Add:キーワードに対し追加または置換
第四引数Mode:動作モード
1=キーワードに接頭辞として第四引数を追加
2=キーワードに接尾辞として第四引数を追加
3=キーワードを第四引数に置換
第五引数Cnt:カウンタ。呼び出し時には1をセットする事
使用例 :
ModList ( "あ¶い¶う¶え¶お¶"; "う"; "追加テキスト!"; 1; 1 )
結果例 :
あ
い
追加テキスト!う
え
お
最終更新日:2008/11/07
*/
Let ( [
Lists = If ( Right ( Lists; 1 ) ≠ "¶"; Lists & "¶"; Lists );
Line = MiddleValues ( Lists ; Cnt ; 1 );
NextData = MiddleValues ( Lists ; Cnt ; PatternCount ( Lists ; "¶" ) )
];
Case (
Mode=1;
If (
Cnt ≤ PatternCount ( Lists ; "¶" );
Case (
PatternCount ( Line ; "¶" & Keyword & "¶" ) > 0;
Substitute ( Line ; Keyword ; Add & Keyword ) & ModList ( Lists; Keyword; Add; 1; Cnt + 1 );
Position ( Line ; Keyword & "¶" ; 1 ; 1 ) = 1;
Substitute ( Line ; Keyword ; Add & Keyword ) & ModList ( Lists; Keyword; Add; 1; Cnt + 1 );
Line & ModList ( Lists; Keyword; Add; 1; Cnt + 1 )
);
Line
);
Mode=2;
If (
Cnt ≤ PatternCount ( Lists ; "¶" );
Case (
PatternCount ( Line ; "¶" & Keyword & "¶" ) > 0;
Substitute ( Line ; Keyword ; Keyword & Add ) & ModList ( Lists; Keyword; Add; 2; Cnt + 1 );
Position ( Line ; Keyword & "¶" ; 1 ; 1 ) = 1;
Substitute ( Line ; Keyword ; Keyword & Add ) & ModList ( Lists; Keyword; Add; 2; Cnt + 1 );
Line & ModList ( Lists; Keyword; Add; 2; Cnt + 1 )
);
Line
);
Mode=3;
Case (
Position ( Line ; Keyword & "¶" ; 1 ; 1 ) = 1;
Substitute ( Line ; Keyword & "¶" ; Add&"¶" );
Position ( Line ; Keyword & "¶" ; 1 ; 1 ) > 1;
Substitute ( Line ; "¶" & Keyword & "¶" ; Add&"¶" );
);
"Error!"
)
)
名 称:ModList ( Lists; Keyword; Add; Mode; Cnt )
概 要:
改行区切りのテキストの中の値に対して接頭/接尾辞の追加、値自体の置換を行う関数。
第一引数Lists:改行区切りの文字列。最後の文字も改行で終わっている事。
第二引数Keywords:キーワード。キーワード中に改行は含まない事。
第三引数Add:キーワードに対し追加または置換
第四引数Mode:動作モード
1=キーワードに接頭辞として第四引数を追加
2=キーワードに接尾辞として第四引数を追加
3=キーワードを第四引数に置換
第五引数Cnt:カウンタ。呼び出し時には1をセットする事
使用例 :
ModList ( "あ¶い¶う¶え¶お¶"; "う"; "追加テキスト!"; 1; 1 )
結果例 :
あ
い
追加テキスト!う
え
お
最終更新日:2008/11/07
*/
Let ( [
Lists = If ( Right ( Lists; 1 ) ≠ "¶"; Lists & "¶"; Lists );
Line = MiddleValues ( Lists ; Cnt ; 1 );
NextData = MiddleValues ( Lists ; Cnt ; PatternCount ( Lists ; "¶" ) )
];
Case (
Mode=1;
If (
Cnt ≤ PatternCount ( Lists ; "¶" );
Case (
PatternCount ( Line ; "¶" & Keyword & "¶" ) > 0;
Substitute ( Line ; Keyword ; Add & Keyword ) & ModList ( Lists; Keyword; Add; 1; Cnt + 1 );
Position ( Line ; Keyword & "¶" ; 1 ; 1 ) = 1;
Substitute ( Line ; Keyword ; Add & Keyword ) & ModList ( Lists; Keyword; Add; 1; Cnt + 1 );
Line & ModList ( Lists; Keyword; Add; 1; Cnt + 1 )
);
Line
);
Mode=2;
If (
Cnt ≤ PatternCount ( Lists ; "¶" );
Case (
PatternCount ( Line ; "¶" & Keyword & "¶" ) > 0;
Substitute ( Line ; Keyword ; Keyword & Add ) & ModList ( Lists; Keyword; Add; 2; Cnt + 1 );
Position ( Line ; Keyword & "¶" ; 1 ; 1 ) = 1;
Substitute ( Line ; Keyword ; Keyword & Add ) & ModList ( Lists; Keyword; Add; 2; Cnt + 1 );
Line & ModList ( Lists; Keyword; Add; 2; Cnt + 1 )
);
Line
);
Mode=3;
Case (
Position ( Line ; Keyword & "¶" ; 1 ; 1 ) = 1;
Substitute ( Line ; Keyword & "¶" ; Add&"¶" );
Position ( Line ; Keyword & "¶" ; 1 ; 1 ) > 1;
Substitute ( Line ; "¶" & Keyword & "¶" ; Add&"¶" );
);
"Error!"
)
)
エンコードは Unicode (UTF-8)、改行タイプは LF (Unix) 形式のテキストとして保存します。
テキストエディタで正常に開かない場合は、エンコードを指定してファイルを開くようにしてください。
詳細説明
改行区切りのテキストの中の値に対して接頭/接尾辞の追加、値自体の置換を行う。この関数が使用する他のカスタム関数
- なし
この関数を使用する他のカスタム関数
- なし
フィードバック
この関数について何かお気づきの点がありましたら、お気づきの点、ご意見、ご感想などをお知らせください。FMPro.info 事務局経由でカスタム関数の作者に転送させていただきます。なお、いただいたフィードバックにつきましては、FMPro.info 事務局から個別にご返信を差し上げておりません。あらかじめご了承いただくようお願いいたします。
注意:ここで紹介されているカスタム関数をご自分のシステムに組み込んだ場合に発生した問題についてはFMPro.infoは責任を負いません。