In the vbs script, folder traversal is used in the middle, and regular matching is performed. Several methods of wscript. Shell object are used.

Source: Internet
Author: User

This script only satisfies part of the work I want to complete, and the rest of the content must be completed and debugged in the company.

Script running requires the following conditions:

Ctags.exe in the same directory as the script requires Versions later than 5.8. It mainly needs to support regular expressions and support directory paths following the-r option.

There must be a logic folder under the same level of directory, and a logic file in the folder must comply with the syntax.

The script is as follows:

'''''''''''''''''''''''''''''''''''''''' ''' Initialize some global variables ''' '''''''''''''''''''''''''''''''''''''''' ''' dim fsodim wshshell, oexecset wshshell = Createobject ("wscript. shell ") set FSO = Createobject (" scripting. fileSystemObject ") '''''''''''''''''''''''''''''''''''''''' ''' display logic ''' '''''''''''''''''''''''''''''''''''''''' ''''' ''' Const sw_logic_in_dlg = 0 const insert_logic_to_script = 1 const open_logic_file = 2 ''''''''''''''''''''''''''''''''''''''' ''' '''window style '''' '''''''''''''''''''''''''''''''''''''''' ''' const sw_hide = 0 const sw_show = 1 const sw_min = 2 const sw_max = 3 '''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''' ''' By drive. the constant ''''''''''''''''''''''''''''''''''''' ''' const drivetyperemovable = 1 const drivetypefixed = 2 const drivetypenetwork = 3 const drivetypecdrom = 4 const drivetyperamdisk = 5 ''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''' ''' by file. the constant ''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''' 'Const fileattrnormal = 0 const fileattrreadonly = 1 const fileattrhidden = 2 const fileattrsystem = 4 const partition = 8 const fileattrdirectory = 16 const fileattrarchive = 32 const partition = 64 const partition = 128 ''' '''''''''''''''''''''''''''''''''''''''' ''' the constant used to open the file ''''' '''''''''''''''''''''''''''''''''''''''' ''' const openfil Eforreading = 1 const openfileforwriting = 2 const openfileforappending = 8 function generatefileinformation (File) dim S = newline & "Path:" & tabstop & file. path S = S & newline & "name:" & tabstop & file. name S = S & newline & "type:" & tabstop & file. type S = S & newline & "attribs:" & tabstop & showfileattr (File) S = S & newline & "created:" & tabstop & file. datecreated S = S & newline & "AC Cessed: "& tabstop & file. datelastaccessed S = S & newline & "modified:" & tabstop & file. datelastmodified S = S & newline & "size" & tabstop & file. size & newline generatefileinformation = Send functionfunction getfolderlastmodifytime (folderpath) if (FSO. fileexists ("tags") then set file = FSO. getFile ("tags") lastmodtime = file. datelastmodified 'msgbox lastmodtime else MSG = filespec & "doesn' t Exist. "'msgbox MSG end if set folder = FSO. getfolder (folderpath) foldermodtime = folder. datelastmodified ltime = folder. datelastmodified set files = folder. files for each file in files if ltime <file. datelastmodified then ltime = file. datelastmodified end if next getfolderlastmodifytime = ltimeend functionfunction flashtagfile (tagfilename, folderpath) if (FSO. fileexists (tagfilename) then set File = FSO. getFile (tagfilename) lastmodtime = file. datelastmodified else strcmd = "ctags.exe -- langdef = logic -- langmap = logic :. logic -- RegEx-logic = ""/^ \ s * (logic | join) \ s + (\ W +) \ s + \ {/\ 2/L, logic/""-n-R "& folderpath oexec = wshshell. run (strcmd, sw_hide, true) flashtagfile = true exit function end if lastmodtime <getfolderlastmodifytime (folderpath) Then strcmd = "ctags.exe -- langdef = logic -- langm AP = logic :. logic -- RegEx-logic = ""/^ \ s * (logic | join) \ s + (\ W +) \ s + \ {/\ 2/L, logic/""-n-R "& folderpath oexec = wshshell. run (strcmd, sw_hide, true) flashtagfile = true else flashtagfile = false end if end functionfunction locationlogic (logicname, logicfilename, linenum) locationlogic = "it's just a empty function now! "& Vbcrlf _ &" it will find ["& logicname &"] in file ["& logicfilename &"]. line: "& linenum end functionfunction getlogicinfo (logicname, tagfilename) dim ore, omatch, omatches set tagfile = FSO. getFile (tagfilename) set textstream = FSO. opentextfile (tagfilename, openfileforreading) alllogicinfo = textstream. readall textstream. close 'the format as below' testlogic010logic \ logic0.logic24; "L Set ORE = new Regexp ore. pattern = logicname & "\ s + (.*?) \ S + (\ D +); "" \ s + (\ W) "'to obtain the matches set ore. ignorecase = false. Ore. Global = false' sets full match. Set omatches = ore. execute (alllogicinfo) If omatches. count = 0 then msgbox "can not find this logic <" & logicname & ">" getlogicinfo = "" exit function else set omatch = omatches (0) filepath = omatch. submatches (0) linenum = omatch. submatches (1) end if getlogicinfo = locationlogic (logicname, filepath, linenum) set ORE = nothing end functionfunction compute () 'It is empty now ready = "testlogic99956" End functionfunction getlogicfilepath () 'the Registry that can be read in this way is restricted. The more powerful method is to use winmgmts object to read, but this simple getlogicfilepath = wshshell is not available. regread ("HKEY_LOCAL_MACHINE \ SOFTWARE \ Evernote \ Installer") getlogicfilepath = "logic" End functionfunction insertlogicinfotoscript (logicinfo) 'It is empty now insertlogicinfotoscript = "it is empty now" End functionfunction openlogicfileingtr () 'The Method for Finding the number of logical files and the number of lines in the logic is the same as the function getlogicinfo. insertlogicinfotoscript = "it is empty now" End functionfunction main () set objargs = wscript. arguments if objargs. count> 0 then showmethod = objargs (I) end if logicname = getlogicnamefromgtr () flashtagfile "tags", getlogicfilepath () logicinfo = getlogicinfo (logicname, "tags ") select case showmethod '64 means show "Information Mark" icon. 'Case sw_logic_in_dlg wshshell. popup (logicinfo, 10, "logic prompt, disappears after 10 seconds", 64) Case insert_logic_to_script insertlogicinfotoscript logicinfo case open_logic_file openlogicfileingtr case else wshshell. popup logicinfo, 10, "logic prompt, disappears after 10 seconds", 64 end selectend functionstarttime = timermainendtime = timertimeit = endtime-starttimemsgbox "cast time" & timeit
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.