ひとりゴト

スクリプト作成補助

AX スクリプト実行時に表示されるエラー行へ飛ぶスクリプト。
単体で動く形に編集してみた。手元ではタイトルかクラスで分岐させてる。

サクラエディタは入力補助機能もあるのでお世話になってる。最低限の使い方すら把握できてないけど^^;
■サクラエディタ
SakuraDebug() //この行を定期的に呼ぶだけでいい。例えば、

While TRUE;Sleep(0.3)
  SakuraDebug()
Wend

Procedure SakuraDebug()
  aw = Getid(GET_ACTIVE_WIN)
  awTitle = Status(aw, ST_TITLE)
  awClass = Status(aw, ST_CLASS)

  If awClass <> "TFmsgDlg.UnicodeClass" Then Exit
//エラーUWSファイル名確定
uwsName = chgmoj(awTitle, "UWSC - ","")

  EditorID = Getid(uwsName, "TextEditorWindow")
  If EditorID < 0 Then Exit

  if Pos("- sakura", Status(EditorID, ST_TITLE)) = 0 Then Exit

  x = Status(aw, ST_X)
  y = Status(aw, ST_Y) + Status(aw, ST_HEIGHT)
  Ifb SlctBox(SLCT_BTN,0, x, y, "エラーを確認", "する", "しない") = SLCT_1
    Clkitem(aw, "OK", CLK_BTN)
    acw(EditorID)
     errLine = sakuraエラー行特定()
     If errLine > 0 then sakura指定行へジャンプ(EditorID, errLine)
    Sleep(3)
   Else
     Sleep(3)
     Exit
   EndIf
Fend

Procedure Sakura指定行へジャンプ(EditorID, errLine)
  JumpID = Getid("指定行へジャンプ", "#32770")  
  Ifb JumpID < 0 then
    SCKEY(EditorID, VK_CTRL, VK_J);Sleep(0.2)
  Endif
  JumpID = getid("指定行へジャンプ", "#32770")
  If JumpID < 0 then exit

  SendStr(JumpID, errLine, 1, TRUE)
  ret = ClkItem(JumpID,"ジャンプ",CLK_BTN)
  If ret = FALSE Then MsgBox("err CLKITEM(ID, ジャンプ, CLK_BTN)")
  Sleep(0.3)
Fend

Function sakuraエラー行特定()
  RESULT = FALSE
//不要
logID = fopen(GET_UWSC_DIR + "\uwsc.log", F_READ)
  If logID < 0 Then Exit

  log行 = FGET(logID, FGET(logID, -1))
//最後の行を取得
行目POS = Pos("行目", log行)
  If 行目POS = 0 Then Exit
//行目が無ければExit
  //行目より前の文字を取得してTRIMで末尾の不要文字削除してVALで数値変換
errLine = Val(Trim(Copy(log行, 1, 行目POS - 1)))

//数値にならなければ数字部分を抜き出し
Ifb errLine = false Then
    コロンPOS = Pos(":", errLine)
//行よりもコロンが後にあればExit
If コロンPOS = 0 or コロンPOS > 行目POS Then Exit
//コロンと行の間をコピーしてTRIMしてVAL
errLine = Val(Trim(Copy(errLine, コロンPOS + 1, 行目POS - 1)))
  EndIf

  Fclose(logID)
  RESULT = errLine
Fend

■K2Editor(編集中)



© Rakuten Group, Inc.
X
Create a Mobile Website
スマートフォン版を閲覧 | PC版を閲覧
Share by: