Wlist.EnableMenuItems: Sub EnableMenuItems() FileSave.enabled = true End Sub Wlist.Resized: Sub Resized() dim l as integer l = LenB(Wlist.Llist.cell(0,1)) Llist.ColumnWidths = str((Llist.width - (l * 10))\2) + "," + str(l * 10) + "," + str((Llist.width - (l * 10))\2) + ",0,0" End Sub Wlist.Llist.DoubleClick: Sub DoubleClick() dim stream as TextInputStream dim keypos as integer App.OrgFile = GetFolderItem(me.cell(me.listindex, 4)) stream = App.OrgFile.OpenAsTextfile Wtext.Etext.text = stream.readall Wtext.title = App.OrgFile.name keypos = Val(me.cell(me.listindex, 3)) Wtext.Etext.selstart = keypos - 1 Wtext.Etext.sellength = lenB(me.cell(0, 1)) Wtext.show End Sub Wmain.Bsearch.Action: Sub Action() dim stream as textinputstream dim path(0), text, pre, post as string dim paths, keypos, n, m, keylen, i, j as integer if Ekey.text = "" or Enumber.text = "" or Ernumber.text = "" then msgbox "キーワードか文字数が指定されていません。" return end if App.Cancel = false Wfiles.showmodal if App.Cancel = true then return end if if App.paths = "" then msgBox "ファイルを指定して下さい。" return end if 'カーソルを時計に Wmain.MouseCursor = WatchCursor App.MouseCursor = WatchCursor Wwait.show Wwait.refresh '### 検索ルーチン ### Wlist.visible = false Wlist.title = Ekey.text Wlist.Llist.DeleteAllRows Wlist.Llist.columncount = 5 paths = Countfields(App.paths, chr(9)) - 1 redim path(paths) for i = 0 to paths - 1 path(i) = NthField(App.paths, chr(9), i + 1) Wwait.Lmsg.text = "検索中です:" + chr(13) + path(i) Wwait.refresh App.OrgFile = GetFolderItem(path(i)) stream = App.OrgFile.OpenAsTextfile text = stream.readall stream.close keylen = Len(Ekey.text) keypos = instr(text, Ekey.text) n = Val(Enumber.text) m = Val(Ernumber.text) while keypos > 0 if keypos < n then pre = Left(text, keypos - 1) else pre = Mid(text, keypos - n, n) end if post = Mid(text, keypos + keylen, m) Wlist.Llist.addrow ReplaceAll(pre, Chr(13), " ") Wlist.Llist.cell(Wlist.Llist.LastIndex, 1) = Ekey.text Wlist.Llist.cell(Wlist.Llist.LastIndex, 2) = ReplaceAll(post, Chr(13), " ") Wlist.Llist.cell(Wlist.Llist.lastindex, 3) = str(instrB(text, Ekey.text + post)) Wlist.Llist.cell(Wlist.Llist.lastIndex, 4) = path(i) keypos = instr(keypos + 1, text, Ekey.text) wend next Wwait.Lmsg.text = "整形中です。" Wwait.refresh if Wlist.Llist.listcount = 0 then Wwait.close msgBox "このキーワードは見つかりませんでした。" Wmain.MouseCursor = ArrowCursor App.MouseCursor = ArrowCursor 'カーソルを戻す Wmain.MouseCursor = ArrowCursor App.MouseCursor = ArrowCursor return end if 'Keyword を bold に。 j = Wlist.Llist.listcount - 1 for i = 0 to j Wlist.Llist.cellbold(i, 1) = true next Wwait.close Wlist.show 'カーソルを戻す Wmain.MouseCursor = ArrowCursor App.MouseCursor = ArrowCursor End Sub Wmain.Enumber.TextChange: Sub TextChange() dim code as integer code = Asc(mid(me.text, len(me.text))) if code < 48 or code > 57 then beep me.text = left(me.text, len(me.text) - 1) me.selstart = len(me.text) end if 'Ernumber.text = me.text End Sub App.OpenList: Sub OpenList() dim file as folderitem dim stream as textinputstream dim text, data(5) as string dim i, j, n, tabpos as integer file = GetOpenFolderItem("text") if file = nil then return end if stream = file.OpenAsTextfile Wlist.visible = false Wlist.title = file.name Wlist.Llist.DeleteAllRows while stream.EOF <> true text = stream.readline tabpos = Instr(text, chr(9)) n = 0 j = Wlist.Llist.ColumnCount - 1 for i = 0 to j data(i) = mid(text, n + 1, tabpos - n - 1) n = tabpos tabpos = Instr(n + 1, text, chr(9)) next Wlist.Llist.addrow data(0) 'j = Wlist.Llist.ColumnCount - 1 for i = 1 to j Wlist.Llist.cell(Wlist.Llist.LastIndex, i) = data(i) next wend 'Keyword を bold に。 j = Wlist.Llist.listcount - 1 for i = 0 to j Wlist.Llist.cellbold(i, 1) = true next stream.close Wlist.visible = true End Sub App.EnableMenuItems: Sub EnableMenuItems() FileMain.enabled = true if WindowCount > 0 then FileClose.enabled = true end if FileOpen.enabled = true End Sub App.Open: Sub Open() Wmain.Show End Sub Wfiles.ShowFolder: Sub ShowFolder() dim f as folderitem dim p as picture dim i, j, n, m as integer Lfolder.deleteAllRows if Ubound( App.dirpath ) = 0 then 'Desktop の場合 j = VolumeCount-1 for i=0 to j f=Volume(i) Lfolder.addrow f.name Lfolder.cell(Lfolder.Lastindex, 1) = f.AbsolutePath Lfolder.CellBold( Lfolder.LastIndex, 0 ) = True 'Lfolder.rowpicture(Lfolder.lastindex) = HDIcon next for i = 0 to j f = getfolderitem( Volume(i).name + ":Desktop Folder" ) n = f.Count for m = 1 to n if f.item(m).visible = true then Lfolder.addrow f.item(m).name if f.item(m).directory = True Then Lfolder.CellBold( Lfolder.LastIndex, 0 ) = True end if Lfolder.cell(Lfolder.Lastindex, 1) = f.item(m).AbsolutePath end if next next else '他の folder の場合 '子 FolderItem 一覧 f=getfolderItem( App.dirpath( Ubound( App.dirpath ) )) j = f.Count for i = 1 to j if f.item(i).visible = true then Lfolder.addrow f.item(i).name if f.item(i).directory = True Then Lfolder.CellBold( Lfolder.LastIndex, 0 ) = True end if Lfolder.cell(Lfolder.Lastindex, 1) = f.item(i).AbsolutePath 'if f.item(i).directory then 'p = folderIcon 'else 'p = fileicon 'end if 'Lfolder.rowPicture(Lfolder.lastIndex) = p end if next end if End Sub Wfiles.AddFile: Sub AddFile() dim f as folderitem dim s, filepath as string dim i, n as integer '既存ファイルリスト作成 n = Lfiles.listcount - 1 filepath = "" for i = 0 to n filepath = filepath + Lfiles.cell(i, 1) + chr(9) next 'ファイルを追加 f = GetFolderItem( Lfolder.Cell( Lfolder.ListIndex, 1 ) ) 'f = GetFolderItem(App.dirpath + Lfolder.text) if f.directory = false and f.MacType = "text" then 'textfile の場合 '重複チェックして追加 if Instr(filepath, f.AbsolutePath) = 0 then Lfiles.Addrow f.name Lfiles.cell(Lfiles.Lastindex, 1) = f.AbsolutePath else beep msgBox "このファイルはすでに選択されています。" return end if end if End Sub Wfiles.Close: Sub Close() dim i, j as integer dim s as string s = "" j = Lfiles.ListCount - 1 for i = 0 to j s = s + Lfiles.cell(i, 0) + chr(9) s = s + Lfiles.cell(i, 1) + chr(13) next App.files = s End Sub Wfiles.Open: Sub Open() dim line, tmpstr as string dim i, n, ret, tab as integer Badd.enabled = false Bdelete.enabled = false tmpstr = App.files n = CountFields(App.files, chr(13)) - 2 for i = 0 to n ret = Instr(tmpstr, chr(13)) line = Left(tmpstr, ret - 1) tmpstr = Mid(tmpstr, ret + 1) tab = Instr(line, chr(9)) Lfiles.AddRow Left(line, tab - 1) Lfiles.cell(Lfiles.LastIndex, 1) = Mid(line, tab + 1) next End Sub Wfiles.Pfolder.Open: Sub Open() dim i, j as integer Pfolder.deleteAllRows Pfolder.Addrow "Desktop" if Ubound( App.dirpath ) = 0 then 'root dir の場合 Pfolder.listindex = 0 else '他の folder の場合 j = CountFields( App.dirpath( Ubound( App.dirpath )), ":" ) for i = 1 to j - 1 Pfolder.Addrow Nthfield( App.dirpath( Ubound( App.dirpath )), ":", i ) next Pfolder.Listindex = i - 1 end if End Sub Wfiles.Pfolder.Change: Sub Change() dim s as string dim i as integer 'if me.listcount - 1 > me.listindex + 1 then for i = me.listcount - 1 downto me.listindex + 1 Pfolder.removeRow i App.dirpath.Remove Ubound( App.dirpath ) next 'end if ShowFolder End Sub Wfiles.Lfolder.DoubleClick: Sub DoubleClick() dim f as folderitem dim i as integer f = GetFolderItem( me.Cell( me.ListIndex, 1 ) ) if f.directory = true then Pfolder.addrow me.Cell( me.ListIndex, 0 ) App.dirpath.Append f.AbsolutePath Pfolder.ListIndex = Pfolder.listcount - 1 else 'file の場合 AddFile end if End Sub Wfiles.Lfolder.Change: Sub Change() dim f as folderitem dim s as string dim i, j as integer if me.listindex = -1 then Badd.enabled = false elseif Ubound( App.dirpath ) = 0 then Badd.enabled = true Badd.caption = "Open" else s = "" j = Pfolder.listcount - 1 for i = 1 to j s = s + Pfolder.list(i) + ":" next s = s + me.text f = getfolderItem(s) if f.MacType = "TEXT" then Badd.enabled = true Badd.caption = "Add >>" elseif f.directory then Badd.enabled = true Badd.caption = "Open" else Badd.enabled = false end if end if End Sub Wfiles.Lfiles.DoubleClick: Sub DoubleClick() Lfiles.removeRow Lfiles.ListIndex End Sub Wfiles.Lfiles.Change: Sub Change() if me.listindex = -1 then Bdelete.enabled = false else Bdelete.enabled = true end if End Sub Wfiles.Badd.Action: Sub Action() dim f as folderitem dim i as integer f = GetFolderItem( App.dirpath( Ubound( App.dirpath )) + Lfolder.text + ":") if f.directory = true then Pfolder.addrow Lfolder.text Pfolder.listindex = Pfolder.listcount - 1 else 'file の場合 AddFile end if End Sub Wfiles.Bdelete.Action: Sub Action() Lfiles.removeRow Lfiles.ListIndex End Sub Wfiles.Bsearch.Action: Sub Action() dim i, j as integer dim s as string s = "" j = Lfiles.listcount - 1 for i = 0 to j s = s + Lfiles.cell(i, 1) + chr(9) next App.paths = s Wfiles.close End Sub Wfiles.Bcancel.Action: Sub Action() App.paths = "" App.Cancel = true self.close End Sub Wfiles.Baddall.Action: Sub Action() dim f as folderitem dim s, filepath as string dim i, j, n as integer '既存ファイルリスト作成 n = Lfiles.listcount filepath = "" for i = 0 to n - 1 filepath = filepath + Lfiles.cell(i, 1) + chr(9) next '全ファイルを追加 n = Lfolder.listcount - 1 for j = 0 to n f = GetFolderItem( App.dirpath( Ubound(App.dirpath) ) + Lfolder.list(j)) if f.directory = false and f.MacType = "text" then 'textfile の場合 '重複チェックして追加 if Instr(filepath, f.AbsolutePath) = 0 then Lfiles.Addrow f.name Lfiles.cell(Lfiles.Lastindex, 1) = f.AbsolutePath end if end if next End Sub