Macro/投稿/165 の変更点

http://sakura.qp.land.to/?Macro%2F%C5%EA%B9%C6%2F165


Top > Macro > 投稿 > 165
  • 追加された行はこの色です。
  • 削除された行はこの色です。
  • Macro/投稿/165 へ行く。

* 等差数列の挿入 [#k550bc98]
-ページ: [[Macro/投稿]]
-作者: [[かくれんbぽ]]
-カテゴリー: ppa
-投稿日: 2007-02-09 (金) 10:38:43

** メッセージ [#ub34e205]
現在のカーソル位置から
・初期値
・差分
・繰り返し回数
・数値の左右に挿入する文字列
・数値を入力する方向
を指定して、等差数列を挿入します。



---------------------------------------
#code{{
//等差連番挿入
var
intCnt,intDef,intCount:integer;
strBuff,strDist,strLeft,strRight:string;
begin
    strBuff := InputBox('初期値入力','連番の初期値を入力してください。','');    // 初期値 入力
    if( strBuff = '') then exit;                                                // キャンセルまたは入力がない場合は終了
    intCnt := StrToInt(strBuff);                                                // 挿入数値の初期値

    strBuff := InputBox('差分入力','連番の差分を入力してください。','');        // 差分 入力
    if( strBuff = '') then exit;
    intDef := StrToInt(strBuff);                                                // 更新する際の差分

    repeat
        strBuff := InputBox('繰り返し回数入力','繰り返す回数を入力してください。','');  // 繰り返し回数 入力
        if( strBuff = '') then exit;
        intCount := StrToInt(strBuff);                                                  // 挿入回数
        if( intCount <= 0 ) then                                                        // 繰り返し回数 確認
        begin
            intCount := MessageBox('繰り返し回数は1以上の整数を指定してください。',
                                   '繰り返し回数 入力 エラー',$15);                     // エラーメッセージ 表示  flg:エラーアイコン + [再試行]&[キャンセルボタン]
            if ( intCount = 2 ) then
                exit                                                                    // キャンセルの場合 終了
            else
                intCount := -1;                                                         // 再試行の場合 繰り返す為に-1をとりあえず設定
        end;
    until (intCount > 0);                                                               // 繰り返し回数が1以上 終了

    strLeft := InputBox('左側挿入文字入力','数値の左側に挿入する文字列を入力してください。','');    // 左挿入文字列 入力
//  if( strLeft = '') then exit;                                                                    // 何も挿入しない場合に対応できない為、コメントアウト

    strRight := InputBox('右側挿入文字入力','数値の右側に挿入する文字列を入力してください。','');   // 右挿入文字列 入力
//  if( strRight = '') then exit;

    strDist := InputBox('移動する方向を数字で入力してください','↑: 8, ↓: 2, →: 6, ←: 4','');    // 移動する方向 入力
    if( strDist = '') then exit;

    while ( intCount > 0 ) do
    begin
        S_MoveHistSet;                                              // 現在位置 記録
        S_InsText ( strLeft + IntToStr(intCnt) + strRight );        // 数値 挿入
        if ( strDist = '8' ) then                                   // 上に移動する場合
        begin
            S_MoveHistPrev;                                         // 挿入する前の位置へ戻って
            S_Up;                                                   // 上へ移動
        end
        else if ( strDist = '2' ) then                              // 下に移動する場合
        begin
            S_MoveHistPrev;                                         // 挿入する前の位置へ戻って
            S_Down;                                                 // 下へ移動
        end
        else if ( strDist = '4' ) then                              // 左に移動する場合
            S_MoveHistPrev                                          // 挿入する前の位置へ戻る
        else                                                        // 右に移動する場合
        ;                                                           // 何もしない
        intCnt := intCnt + intDef;                                  // 挿入数値 更新
        intCount := intCount - 1;                                   // 挿入回数 更新
    end;
end;
}}
----

#comment

    ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS