정해준 경로의 소스를 출력하는 함수를 간단하게 만들어보았습니다.
당연한 말이겠지만 같은 사이트 내의 소스만 출력이 됩니다.
Replace 부분에서 매번 strText 변수에 재할당하지 않고 한줄로 한번에 변환하는 것이 실행 효율이 조금 더 낫지만, 저렇게 Replace 항목이 많은 경우에는 여러줄로 나누어 보기 좋게 해주는 것이 수정을 편하게 하여 유지보수 생산성이 높아집니다.
<code> 태그는 코드를 화면에 출력할때 사용하는 <xmp> 태그와 유사한 동작을 합니다.
함수내에서 화면 출력에 필요한 작업을 이미 대부분 해놓은 상태이므로 코드 출력용 태그는 사실상 불필요합니다. 위의 경우는 단순히 보기 좋으라고 <code> 태그를 붙여놓은 것이므로 제거하셔도 무방합니다.
참고로 <code> 태그 위치에 <xmp> 태그를 대신 사용하면 사소한 문제가 하나 생기니 주의하시길 바랍니다.
============================================================================================================================
늦어지만 저도 답변달아 봅니다.
아래와 같이 보여지게 만들어 줍니다.
<%
Sub viewCode(codefile)
response.write "<p style=""background-color=#eeeeee;"">"
set fso = server.createobject("scripting.filesystemobject")
set f = fso.opentextfile(server.mappath(codefile),1)
allViewCode = viewHTML(f.readall)
set f = nothing
response.write codingcolor(allviewcode,"brown")
response.write "</p>"
End Sub
'Coding부분을 찾아서 Coloring함수로...
function CodingColor(strTemp,strFontColor)
Dim firstPos
Dim lastPos
Dim leftString
Dim midString
Dim rightString
Dim xmidString
firstPos =1
lastPos = 1
do until lastPos >= len(strTemp)
firstPos = instr(lastPos, strTemp, "<%")
if firstPos <= 0 then
exit do
end if
lastPos = instr(firstPos, strTemp, "%>")
if lastPos <= 0 then
lastPos = len(strTemp)
end if
lastPos = lastPos + len("%>") - 1
leftString = left(strTemp,firstPos-1)
midString = mid(strTemp,firstPos,lastPos-firstPos+1)
rightString = mid(strTemp,lastPos+1,len(strTemp)-lastPos)
xmidString = coloring(midString)
' strTemp = leftString & xmidString & rightString
' lastPos = firstPos + len(xmidString)-1
strTemp = leftString & "<span style=color:" & strFontColor & ";>" & xmidString & "</span>" & rightString
lastPos = firstPos + len("<span style=color:" & strFontColor & ";>" & xmidString & "</span>")-1
loop
CodingColor = strTemp
end function
function coloring(strViewCode)
Dim Reservedwords
Dim aryReservedword
Dim i
Dim strFunction
Dim aryFunction
Reservedwords="AndlCalllCaselConstlDimlDolEachlElselElseIflEmptylEndlEqvlEraselErrorlExitlExplicitlFalselForlFunctionlIflImplInlIslLooplModlNextlNotlNothinglNulllOnlOptionlOrlPrivatelPubliclRandomizelReDimlResumelSelectlSetlSteplSublThenlTolTruelUntillWendlWhilelXor"
aryReservedword=split(Reservedwords,"l")
for i = 0 to ubound(aryReservedword)
strViewCode = wordReplace(strViewCode,aryReservedword(i),"blue")
next
strFunction="AnchorlArraylAsclAtnlCBoollCBytelCCurlCDatelCDbllChrlCIntlCLnglCoslCreateObjectlCSnglCStrlDatelDateAddlDateDifflDatePartlDateSeriallDateValuelDaylDictionarylDocumentlElementlErrlExplFileSystemObjectlFilterlFixlIntlFormlFormatCurrencylFormatDateTimelFormatNumberlFormatPercentlGetObjectlHexlHistorylHourlInputBoxlInStrlInstrRevlIsArraylIsDatelIsEmptylIsNulllIsNumericlIsObjectlJoinlLBoundlLCaselLeftlLenlLinklLoadPicturelLocationlLoglLTrimlRTrimlTrimlMidlMinutelMonthlMonthNamelMsgBoxlNavigatorlNowlOctlReplacelRightlRndlRoundlScriptEnginelScriptEngineBuildVersionlScriptEngineMajorVersionlScriptEngineMinorVersionlSecondlSgnlSinlSpacelSplitlSqrlStrComplStringlStrReverselTanlTimelTextStreamlTimeSeriallTimeValuelTypeNamelUBoundlUCaselVarTypelWeekdaylWeekDayNamelWindowlYear"
aryFunction=split(strFunction,"l")
for i = 0 to
번호 | 제목 | 닉네임 | 조회수 | 작성일 | |
---|---|---|---|---|---|
95 | 익스플러 플래시 사용스크립트 [1] | 웹아티 | 2627 | 2006.04.21 | |
94 | 자동등업 방법[조금 무식한 방법입니다.] [8] | 박인영 | 2641 | 2007.05.24 | |
93 | 이미지 등록시 이미지파일 체크 자바스크립트_수정2 [2] | 최경수 | 2645 | 2007.07.11 | |
92 | 패스코리아의 Nwmail 사용사시는분 [5] | 네오지기 | 2670 | 2006.08.23 | |
91 | 달력스킨에서 데이터를 뽑아서 사용할시 링크방법 [2] | 홍정우 | 2688 | 2007.01.08 | |
90 | 아티보드 오늘 생일자 목록 뽑기 [3] | 웹아티 | 2699 | 2007.05.30 | |
89 | 아티보드 3.0 팝업 띠우기 | 일천 | 2747 | 2012.06.20 | |
88 | 우편번호 삽입시, [1] | 행복한떠기 | 2771 | 2007.09.26 | |
87 | 첨부파일 올립니다. 참고하세요!! [5] | 박인영 | 2784 | 2007.11.09 | |
86 | 조회수별, 코멘트 글수별 게시글 추출 소스입니다. [2] | 천명관 | 2786 | 2007.02.26 | |
85 | GeoIP 국가별 IP 체크 방법 | 최백호 | 2788 | 2011.11.25 | |
84 | jquery를 이용한 오른쪽 퀵메뉴 | 최백호 | 2790 | 2011.11.25 | |
83 | 등록자에 별명으로 입력되게 하기 [5] | 에버클럽 | 2798 | 2006.06.15 | |
82 | 다운로드 제한 걸기!!! [2] | 박인영 | 2809 | 2007.07.13 | |
81 | 설치시 424에러가 뜰 경우 [3] | 행복한떠기 | 2824 | 2007.09.23 | |
80 | 정식 싸이트 개설했습니다. 많이들 놀러 오세요... [3] | 박인영 | 2832 | 2007.05.29 | |
79 | nmail을 사용하시면서 아팁보드에서 메일발송시 HTML형태로 발송이.. [1] | 김유진 | 2837 | 2007.05.12 | |
ASP 소스 보기 | 최백호 | 2882 | 2011.11.25 | ||
77 | XP Pro에서 폴더별 권한 설정방법 [2] | 정기성 | 2889 | 2006.09.11 | |
76 | 예) 48시간 안에 작성된 글중! 조회수 높은 순으로 뽑기... [1] | 리안 | 2902 | 2008.02.21 |
댓글 0