'=================================================================== 
'==    설명 : 문장을 해당 자릿수만큼 <br>이 들어간 문장으로 변환 
'==    이름 : MakeBr(Str,Pos) 
'==    변수 : Str(String),Pos(Int) 
'==    반환 : String 
'=================================================================== 
Function MakeBr(Str,Pos) 
    Dim StrLen, TmpStr, i, Midcnt, Start, Surplus 
    
    StrLen = len(Str) 
    
    If (StrLen Mod Pos) = 0 then 
        MidCnt = Fix(StrLen/Pos) 
    Else 
        MidCnt = Fix(StrLen/Pos) + 1 
    End If 
    
    for i = 1 to MidCnt 
        if i = 1 then 
            TmpStr = TmpStr&Mid(Str,i,pos)&"<br>" 
        Else 
            TmpStr = TmpStr&Mid(Str,((i-1)*Pos)+1,pos)&"<br>" 
        End If 
    next 
    
    MakeBr = TmpStr 
End Function 
' ################################################################################## 
' 검색에서 selected 
' ################################################################################## 
Function getSelected(search,t) 
    if search = t then 
        getSelected ="selected" 
    end if 
End function  
' ################################################################################## 
' checked 
' ################################################################################## 
Function getChecked(tag,y) 
    If tag = y then 
        getChecked = "checked" 
    End if 
End function 
' ################################################################################## 
' 자동링크 
' ################################################################################## 
  FUNCTION autolink(CONTENT) 
  
    DIm Re 
    Set re = New RegExp 
    
    ' First Pass for http 
    re.Pattern = "(\w+):\/\/([^/:]+)(:\d*\b)?([^# \n<]*).*\n" 
    re.Pattern = "http://([0-9a-zA-Z./@:~?&=_-]+)" 
    re.Global = True 
    re.IgnoreCase = True 
    
    ' ASP seems to be not supporting .MultiLine method. 
    're.MultiLine = True 
    
    CONTENT = re.Replace(CONTENT,"<a target=_blank href='http://$1'>http://$1</a>") 
    
    ' Second Pass for mail 
    re.Pattern = "([_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+)*)@([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)" 
    autolink = re.Replace(CONTENT,"<a href='mailto:$1@$3';>$1@$3</a>") 
  
  END FUNCTION  
' ################################################################################## 
' 문자열 체크 (리턴값:boolean) 
' ################################################################################## 
Function chkStrFlag(Val, chkStr) 
    Dim flag, MyPos 
    
    If Val = "" then 
        flag = false 
    Else 
        Mypos =Instr(Val,chkStr) 
        If MyPos = 0 then 
            flag=false 
        Else 
            flag=true 
        End If 
    End If 
    
    chkStrFlag = flag 
End Function 
'################################################################################## 
'    문자열 체크 (공백이나 NULL값 체크) 
'    Val    : 체크 값, r_Val (대체값) 
'################################################################################## 
Function replaceVal(val, r_Val) 
    Dim flag, MyPos 
    
    If (val = "") or IsNull(Val) then 
        replaceVal = r_Val 
    Else 
        replaceVal = val 
    End If 
End Function 
'################################################################################## 
'    숫자값 자릿수만큼 문자로 변경 (공백이나 NULL값 체크) 
'    Val    : 체크 값, chkLen 자릿수 , r_Val(대체값) 
'################################################################################## 
Function chkLenReplaceVal(val,chkLen, r_Val) 
    Dim chkCnt, MyPos 
        chkCnt = len(Cstr(val)) 
    If chkCnt < chkLen then 
        chkLenReplaceVal =  val 
        
        for i = 1 to (chkLen-chkCnt) 
            chkLenReplaceVal = r_Val&chkLenReplaceVal 
        next 
    Else 
        chkLenReplaceVal = val 
    End If 
End Function 
'################################################################################## 
'    널값,""값 확인 
'    Val    : 체크 값 
'    retun 값 : true, false 
'################################################################################## 
Function chkBlank(val) 
    If (val = "") or IsNull(Val) then 
        chkBlank = true 
    Else 
        chkBlank = false 
    End If 
End Function 
'################################################################################## 
'    비교값 리턴 
'    Val    : 체크 값 
'    retun 값 : true, false 또는 대치 문장 
'################################################################################## 
Function replaceStr(str, chkStr, replaceStr1, replaceStr2) 
    If str = chkStr then 
        replaceStr = replaceStr1 
    Else 
        replaceStr = replaceStr2 
    End If 
End Function 
'################################################################################## 
'    NULL값 만들기 
'    Val    : 값 
'    retun 값 : NULL, 문장 
'################################################################################## 
Function makeNull(str) 
    If str="" or IsNull(str) then 
        makeNull = "NULL" 
    Else 
        makeNull = str 
    End IF 
End Function 
'################################################################################## 
'    HTML 태그 지우기 (정규식표현) 
' 인자 : strHTML:문장, patrn : 패턴 문장 
'    retun 값 : String 
'################################################################################## 
Function stripHTML(strHTML, patrn) 
  Dim objRegExp, strOutput 
  Set objRegExp = New Regexp 
  objRegExp.IgnoreCase = True 
  objRegExp.Global = True 
  objRegExp.Pattern = patrn 
  'objRegExp.Pattern = "<.+?>"  '''' 태그완전히없앰 
  strOutput = objRegExp.Replace(strHTML, "") 
  stripHTML = strOutput 
  Set objRegExp = Nothing 
End Function 
'################################################################################## 
' 문자 잘라내기 
'################################################################################## 
Function CutString(Str,Length,Patten) 
  If Len(Str) > Length Then 
    CutString = Left(Str,Length-3) & patten 
  Else 
    CutString = Str 
  End If 
End Function 
별건 아니구요..그냥 가끔 디버깅시에 쓰는 함수에요 
#################################################### 
Sub DbPrintErrMsg(obj) 
Dim errLoop 
    For Each errLoop In obj.Errors 
        response.write "#############<br>" 
        response.write "Error Number: " & errLoop.Number & "<br>" 
        response.write "Description: " & errLoop.Description &  "<br>" 
        response.write "Source: " & errLoop.Source &  "<br>" 
        response.write "SQL State: " & errLoop.SQLState &  "<br>" 
        response.write "Native Error: " & errLoop.NativeError & "<br>" 
        response.write "#############<br>" 
    Next 
End Sub 
########폼값 확인할때################### 
Sub Prt_RequestForm(obj) 
Dim item 
    For Each item In obj 
        response.write "#############<br>" 
        response.write item&" : " &obj(item)& "<br>" 
        response.write "#############<br>" 
    Next 
End Sub 
ex) Prt_RequestForm(Request.Form), Prt_RequestForm(Request.QueryString), 
Prt_RequestForm(UploadForm) 
출처:http://www.raming.co.kr/gnuboard4/bbs/board.php?bo_table=tip&wr_id=16&page=2
'asp' 카테고리의 다른 글
| ASP 기반에서의 트랙백 구현 (3) | 2007.05.03 | 
|---|---|
| isNull, isEmpty, isObject... (0) | 2007.05.03 | 
| 포스트, 겟, 쿠키 , 세션 값확인할때 (0) | 2007.05.03 | 
| The ASP CAPTCHA (자동가입방지) (0) | 2007.05.03 | 
| ASP 기초 - 배열 (0) | 2007.05.03 |