2012年3月26日星期一

Cheap Oakley SunglassesASP according to thetemplate to generate static HTML file &lt % ;exampl

ASP according to thetemplate to generate static HTML file < % ;examples: TPL TPL = New template tpl.setTplPath = " ;../ template / footer.tpl" ;tpl.setTags = array ( " ;< ;!-- { label name } :> ;" ;tpl.
setNotes = array ( " ) ;alternative content " ) ;tpl.setStoreF = " ;." ./ HTML / ; using automatically generated file name in the end of " ;" ;Set TPL = Nothing Class template Private objFso Private strFileCode ---------------------------------------------------------- read the template file content Private intRnd random number generation, combined into the new file name Private tplpath Private StorePath template name files Private StoreFname Private arrTags file name tag array of Private arrNotes in the use of Set to create the object automatically when performing Private Sub Class_Initialize ( set ) objFso = CreateObject ( " ;scripting.
filesystemobject" ;End Sub ) template file location and # 43 ;name of the Public Property Le write only T setTplPath ( ByVal tName ) tplpath = Server.MapPath ( Replace ( tName ," ;/ / " ," / " ;;;) ) End Property storage file location & # 43 ;Public Property Let setStoreF name only write ( ByVal tName ) tName = Replace ( tName ," ;/ / " " ;,;/ " ;) get file name dim arrY arrY = split ( tName ," ;" ;StoreFname ) = Ubound ( arrY ) StoreFname = arrY ( StoreFname ) directory name StorePath = Replace ( tName ,StoreFname ," ;" ;StorePath = Server.
MapPath ( StorePath ) ) End Property Public label write only Property Let setTags ( ByVal strString ) arrTags = strString End Property Public Property Let setNotes content only write ( ByVal strString ) arrNotes = strString End Property generated in the Min between Max and Private Sub from a random number rnd_Integer ( Min ,Max ) Randomize intRnd = CInt ( Max-Min& # ( 43 ;1) * Rnd ( & ) # ) 43 ;Min End Sub :time & # 43 ;Private Sub makeFilename dim fname random number fname = now ( fname ) = replace ( fname ," ;" ;" ," ;fname = replace ( ;) Fname ," ;" ;" ;" ;fname ,replace ) = ( fname ," ;" ;" :" ;,;) fname = replace ( fname ,Dr Beats Headphones," ;PM" ;" ;" ;fname ,replace ) = ( fname ," ," ;" ;AM" ;fname = replace ;) ( fname ,Moncler Kid Uk," ;" ,Christian Louboutin Sale," " morning ;;;) fname = replace ( fname ," ;" ," " afternoon ;;;) call rnd_Integer ( 09999) StoreFname = fname& ;intRnd& ;" ;html" ;fname = null End Sub Private Sub LoadTemplate reads the template file content ( tplpath If objFso.
FileExists ) Then Set FileObj = objFso.GetFile ( tplpath ) Set FileStreamObj = FileObj.OpenAsTextStream ( 1 ) If Not FileStreamObj.AtEndOfStream Then strFileCode = FileStreamObj.ReadAll Else Message 1002 End If Else Message 1001 End If Set FileObj = Nothing: Set FileStreamObj = Nothing End Sub Private Sub updateNotes if updating the page content of IsArray ( arrNotes ) and IsArray ( arrTags ) then if Ubound ( arrNotes ) = Ubound ( arrTags ) then LoadTemplate For intI = Lbound ( arrNotes ) to Ubound ( arrNotes ) strFileCode = Replace ( strFileCode ,arrTags ( intI ) ,arrNotes ( intI ) ) Next else Message 1004 end if else Message 1004 end if End Sub Private Sub makeFold to create the folder ( ByVal strFoladName ) on error resume next folder to determine whether the presence of ( about ,files : objFso.
FileExists ) If false = objFso.FolderExists ( strFoladName Then objFso.CreateFolder ( strFoladName ) ) if err> err.clear Message 1003 end ;0 then if End If End Sub Private Sub makeFile dim arrX file ,intI ,strW strW = " ;" ;arrX = split ( StorePath ," / " ;;) to judge if the directory exists ,decide whether to create a directory For intI = Lbound ( arrX ) to Ubound ( arrX makeFold strW& ) ;arrX ( intI ) strW = strW& ;arrX ( intI ) Next not set file name using the date with the random number as the file name if StoreFname = " ;" ;then makeFilename end if updateNotes updated content ( filename object.
CreateTextFile ,Cheap Oakley Sunglasses,Unicode overwrite ,Set ) objFout = objFso.CreateTextFile ( StorePath& ;" ;/ " ;& ;StoreFname ,true ) objFout.WriteLine strFileCode objFout.close set input objFso = Nothing Message 1000 End Sub prompts the successful implementation of public Sub exeTpl makeFile End Sub Private Sub Message ( ByVal s returned to Select Case s ) Case 1000 Response.
Write " ;the success of operation !" ;& ;StoreFname Case 1001 Response.Write " ;template does not exist ,please bind !" ;Case 1002 Response.Write " ;template content is empty !" Response.
Write " ;Case 1003 ;file creation failed ,Dr Dre Beats!" ;Case Else End Select End Sub in Set release object automatically when performing Private Sub Class_Terminate Set objFso = Nothing
Related articles:

没有评论:

发表评论