BASP21 DLL

Japanese

Release Notes  Sep 11, 2001
BASP21 belongs to Tatsuo Baba
Written by TK Upperfield

This is a comprehensive component, packed with 66 of useful methods, that is able to operated from ASP, Visual Basic, VBA, WSH(Windows Scripting Host).

Down Load! BASP21-20010911.exe (1002KB) Update Sep 11, 2001
MD5: 76706c89a1daffaca2d96159a83584ea

How to Install

Download "BASP21.exe" into certain folder and just double-click it. In next 10-second, installation finishes all work, and shows confirmation, then just press button to close it.
Following files are copied into System Folder.

How to Uninstall

Select BASP21 from [Control Panel] -> [Add/Delete Application]

How to Use

Create object names "basp21" by CreateObject Method.

   Set bobj = Server.CreateObject("basp21")   ' ASP
   Set bobj = CreateObject("basp21")          ' VBA or VB
   Set bobj = WScript.CreateObject("basp21")  ' WSH
Case of 
Socket Object:
   Set bsocket = Server.CreateObject("basp21.socket")   ' ASP
   Set bsocket = CreateObject("basp21.socket")          ' VBA or VB
   Set bsocket = WScript.CreateObject("basp21.socket")  ' WSH
Case of 
FTP Object:
   Set ftp = Server.CreateObject("basp21.FTP")   ' ASP
   Set ftp = CreateObject("basp21.FTP")          ' VBA or VB
   Set ftp = WScript.CreateObject("basp21.FTP")  ' WSH

Call method of Object you just created.

   variable = bobj.method_name(parameter)

If you are using ASP(Active Server Pages), you can create an Application Object by writing a code into global.asa; looks like below,

  <SCRIPT LANGUAGE=VBScript RUNAT=Server>
  SUB Application_OnStart
    Set Application("bobj") = Server.CreateObject("Basp21")
  END SUB
  </SCRIPT>

and declare the object at each asp file as below;

   Set bobj = Application("bobj")

List of Methods

  1. SendMail Send Mail
  2. SendMailEx Send Mail(Asynchronous Mode)
  3. RcvMail Receive Mail
  4. ReadMail Read Mail
  5. Match String Pattern Match(Perl5 Compatible)
  6. Replace String Replace(Perl5 Compatible)
  7. Translate String Translate(Perl5 Compatible)
  8. Split Split(Perl5 Compatible)
  9. FGrep File Pattern Match 2000/06/18 Update!
  10. FileCheck File Check
  11. Sort Sort
  12. ReadDir Read(List) Directory
  13. Space Space
  14. IsNum Check Digits
  15. HAN2ZEN Convert double space char to single space char
  16. RepTagChar Replace HTML Tag
  17. BinaryRead Read Binary Array from File
  18. sprintf "sprintf" Wrapper
  19. strftime "strftime" Wrapper
  20. Debug Dump strings into Notepad
  21. StrConv VB Compatible String Converter
  22. BinaryWrite Write Binary Array into File
  23. FormSaveAs HTML File Upload(Write File)
  24. FormFileName HTML File Upload(File Name)
  25. FormFileSize HTML File Upload(File Size)
  26. Form HTML File Upload(Read Text)
  27. FormBinary HTML File Upload(Read Binary)
  28. Execute Execute Program
  29. Kconv Convert Kanji Code
  30. KconvFile Convert Entire File Kanji Code
  31. BinaryConcat Merge Binary Array
  32. DebugClear Clear the string of Notepad
  33. SplitB Split(Perl5 Compatible) Binary Array
  34. ByteArray Return Binary Array from Strings
  35. MatchEx Extended Pattern Match
  36. Counter GIF Counter
  37. Version Version string
  38. Base64 BASE64 encode/decode
  39. Socket Object 6 methods
  40. FTP Object 12 methods
  41. GetTempFile Make temporary file2000/01/11 New!
  42. W3get Get URL(http:// ftp://) 2000/01/11 New!
  43. MidB Access Binary Array 2000/02/06 New!
  44. MatchBBinary Array Pattern Match(Perl5 Compatible) 2000/02/06 New!
  45. SortMail Sort Mail 2000/02/06 New!
  46. Sleep Sleep 2000/05/20 New!
  47. MD5 Message Digest 2000/05/20 New!

Explanation of Each Method

  1. SendMail

    Sends mail by SMTP-Protocol. (Sync Mode)

    msg = bobj.SendMail(svname,mailto,mailfrom, subj,body,files)
    msg   [out] : Error message
    svname [in]  : Name of SMTP Server.
                   [host.domain/]server[:port[:timeout]]
                   host.domain - HELO host name and domain name.
                   server - server name or IP address.
                   port   - port. default is 25.
                   timeout   - timeout (sec). default is 120.
                   If necessary, locate port number by separating a tab.
    mailto [in]  : Designate receivers' mail address.
                   To set multiple mail addresses, separate them with Tab.
                   Set optional field here, such as cc/bcc/reply-to and other "Mail Header."
    mailfrom [in]  : Designate sender's mail address.
    subj  [in]  : Designate a subject.
                  To leave it blank, enter ""(just two double quotes).
    body  [in]  : Designate a body of mail.
                  To leave it blank, enter ""(just two double quotes).
    files [in]  : Designate a file name to be attached with full path.
                  To leave it blank, enter ""(just two double quotes).
                  To set multiple attached files, separate them with Tab.
    Example:
    svname = "odyssey"   ' Name of SMTP Server
    mailto = "BABAQ <xxxx@xxxx.xxx>"   ' Receiver's mail address
    mailfrom = "somebody <who@who.com>"    ' Sender's mail address
    subj = "Hello w/attached file"   ' Mail Subject
    body = "Hey, what's up ?"        ' Mail Body
    files = "g:\temp\file1.txt" & chr(9) & "g:\temp\file2.txt"   ' Attached Files
    rc = bobj.SendMail(svname,mailto,mailfrom, subj,body,files)
    if rc <> "" then        ' Check Error
      rc is the error statement
    end if
    
    How to use Mail Header:
    
    If you want to designate cc/bcc/reply-to option field, SendMail/SendMailEx Method can handle them.
    To do so, you have to set cc/bcc/reply-to option field in mailto parameter of SendMail Object, by separating each field with tab.
    For further optional field, put ">" in head of each entry.
    
    Examples:
    > Case 1:  Receiver = id1, CC = id2, Message-ID = 12345
    mailto = "id1" & vbtab & "cc" & vbtab & "id2" & vbtab & ">Message-ID: 12345"
    
    > Case 2:  Receiver = id1 and id2, CC = id3
    mailto = "id1" & vbtab & "id2" & vbtab & "cc" & vbtab & "id2"
    
    > Case 3:  Receiver = id1 and id2, CC = id3 and id4
    mailto = "id1" & vbtab & "id2" & vbtab & "cc" & vbtab & "id3"
                                                       & vbtab & "id4"
    
    > Case 4:  Receiver = id1, BCC = id2
    mailto = "id1" & vbtab & "bcc" & vbtab & "id2"
    
    > Case 5:  Receiver = id1, CC = id2, BCC = id3
    mailto = "id1" & vbtab & vbtab & "cc" & vbtab & "id2"
                                              & vbtab & "bcc" & vbtab & "id3"
    
    > Case 6:  Receiver = id1, Reply-To = id2 (not sender but return address)
    mailto = "id1" & vbtab & "reply-to" & vbtab & "id2"
    
    > Case 7:  CC = id2
    mailto = "cc" & vbtab & "id2"
    
    > Case 8:  BCC = id2
    mailto = "bcc" & vbtab & "id2"
    
    > Case 9:  Hide all receivers, except only representative mail address.
    mailto = "common id" & vbtab & "bcc" & vbtab & "id1" & vbtab & "id2"  vbtab & "id3"
    
    
    Enhancing option:
    
    
    1. Representative address name "@to-header" The head is used and the mail address of "@" is used only for the TO header. Therefore, names other than the mail address can be used. Use this with bcc or cc. Example: mailto = "@BASP21-ML-User" & vbTab & "bcc" & vbTab & "who@hoge.com" The TO header is as follows. To: BASP21-ML-User
    2. Forwarding mode ">#xfr file-name" The specified file is forwarded. The file specifies the file made by the RcvMail method. Former To header is deleted. Subject is overwrited. The text and the attached file specified for a parameter are disregarded. The following header is deleted: X-Mailer: X-Mail-Agent: Status: To: Return-Path: Delivered-To: example : mailto = "who@hoge.com" & vbTab & ">#xfr c:\mail\b21xxx.tmp" mailto = "@ML-user" & vbTab & ">#xfr c:\mail\b21xxx.tmp" & vbTab & "bcc" & vbTab & "who@hoge.com"
    3. Header deletion at forwarding mode ">#d" To delete the header of the forwarded mail, this offers the finger. example : mailto = "@ML-user" & vbTab & ">#xfr c:\mail\b21xxx.tmp" & vbTab & ">#dcc:" & vbTab & "bcc" & vbTab & "who@hoge.com"
    4. Bcc file input mode ">#bcc file-name" The mail address is input from the file line by line and mail is transmitted. The transmission address is processed as Bcc not transmitted as a header. Specify only mail ID for the mail address. example : mailto = "@ML-user" & vbTab & ">#xfr c:\mail\b21xxx.tmp" & vbTab & ">#bcc c:\mai\mailto.txt" Content of bcc file: # comment The line of "#" is disregarded as a comment. who@hoge.com who1@hoge.com who2@hoge.com

    You have to use SJIS code, if using Kanji code.  You don't have to worry about double-space character to convert single-space character, because BASP Component would take care of it, instead.  When entering more than one filed at receiver's address or several mail headers or attached file, don't forget to separate them with char(9) (means an ASCII code of Tab).  When SendMail Method is called, the process keeps waiting until SendMail Method will done its job.  To avoid this matter, use SendMailEx Method, which works as an independent process.

  2. SendMailEx

    Basically same function as SendMail Method, but works on different process from original process.  The result will be saved in log file. 

    msg = bobj.SendMailEx(logname,svname,mailto,mailfrom,
                                                   subj,body,files)
    msg   [out] : Error message
    logname [in]  : File name for result log.  Full path is required.
    svname [in]  : Name of SMTP Server.
                   If necessary, locate port number by separating a tab.
    mailto [in]  : Designate receivers' mail address.
                   To set multiple mail addresses, separate them with Tab.
                   Set optional field here, such as cc/bcc/reply-to and other "Mail Haeder."
    mailfrom [in]  : Designate sender's mail address.
    subj  [in]  : Designate a subject.
                  To leave it blank, enter ""(just two double quotes).
    body  [in]  : Designate a body of mail.
                  To leave it blank, enter ""(just two double quotes).
    files [in]  : Designate a file name to be attached with full path.
                  To leave it blank, enter ""(just two double quotes).
                  To set multiple attached files, separate them with Tab.
    Example:
    logname = "g:\temp\maillog.txt"   ' Name full path of log file
    svname = "odyssey"   ' Name of SMTP Server
    mailto = "BABAQ <xxxx@xxxx.xxx>"   ' Reciever's mail address
    mailfrom = "somebody <who@who.com>"    ' Sender's mail address
    subj = "Hello w/attached file"  ' Mail Subject
    body = "Hey, what's up ?"       ' Mail Body
    files = "g:\temp\file1.txt" & chr(9) & "g:\temp\file2.txt" ' Attached Files
    rc = bobj.SendMailEx(logname,svname,mailto,mailfrom, _
                                              subj,body,files)
    if rc <> "" then ' Check Error
      rc is the error statement
    end if

  3. RcvMail

    Receive mail with POP3 Protocol, and save them into a file.  To retrieve the mail, which saved in file, use ReadMail Method.

    output = bobj.RcvMail(svname,user,pass,command,dirname)
    svname [in]  : Name of POP3 Server
                   If necessary, locate port number by separating a tab.
    user   [in]  : User name of MailBox
    pass   [in]  : Passwd of MailBox
                   2000/05/20 APOP supported
                   To use APOP, one blank is applied to "a" or "A" ahead of the password.
                   "a " & "xxxx" : If the server does not support APOP,
                                   usual USER/PASS will be processed. 
                   "A " & "xxxx" : APOP is compelled. USER/PASS will not be used.
    command [in]  : Designate command
           STAT ...... Returns how many mails are stored in mail server and its total byte size.
           LIST [n[-n2]] .. Returns an array of Subject, From, and Date fields, and each field are separated by tab.
                       To set the range, parameter will be n-n2,
                       where retrieving from #n mail to #n2 mail.
                       If n2 is omitted, it returns only #n mail.
                       If both n and n2 are omitted, it returns all(or first 256th) mail.
           SAVE n[-n2] .... Receives #n mail, and does not delete from mail server.
                       To set the range, parameter will be n-n2,
                       where retrieving from #n mail to #n2 mail.
                       If n2 is omitted, it returns only #n mail.
           SAVD n[-n2] ... Receives #n mail, and delete from Mail Server.
                       To set the range, parameter will be n-n2,
                       where retrieving from #n mail to #n2 mail.
                       If n2 is omitted, it returns only #n mail.
           DELE n[-n2] ... Delete #n mail from mail server.
                       To set the range, parameter will be n-n2,
                       where retrieving from #n mail to #n2 mail.
                       If n2 is omitted, it deletes only #n mail.
           SAVEALL ... Receives all mails(up to 256 mails), and does not delete from Mail Server.
           SAVEALLD .. Receives all mails(up to 256 mails), and delete from Mail Server.
    dirname [in] : Directory(folder) name where received mails would be saved.
    output [out] : Returns the result in an array.  It won't return anything if error occurred.
                   The content of array is depended by what command was executed; see below.
           STAT - Number of mails stored in mail server and its total byte size
              Example: output(0) -> 2 4011
           LIST - An array of list which contains Subject、From、and Date fields.
              Example:
                 output(0) -> Subject: Hello\tFrom: xxxx@xxxx.xxx\tDate: 1998/09/15 11:11:30
                 output(1) -> Subject: Hello2\tFrom: xxxx@xxxx.xxx\tDate: 1998/09/15 12:11:30
           SAVE/SAVD/SAVEALL/SAVEALLD - Returns a file name of where received mails are saved.
           DELE - The number deleted mail.
    
    Example:
    svname = "odyssey"   ' Name of POP3Server
    user = "who"     ' User name of MailBox
    pass = "alibaba"     ' Passwd of MailBox
    dirname = "c:\mail\basp21"  ' Directory name to save received mail
    outarray = bobj.RcvMail(svname,user,pass,"SAVE 1-10",dirname)
    if IsArray(outarray) then	' OK ?
       for each file in outarray
          array2 = bobj.ReadMail(file,"subject:from:date:",dirname)
          if IsArray(array2) then	' OK ?
            for each data in array2
               Response.Write Server.HTMLEncode(data)
            next
          endif
       next
    end if
    

  4. ReadMail

    Read mail which already received by RcvMail Method.

    output = bobj.ReadMail(file,para,dirname)
    file   [in]  : File name with full path.
    para   [in]  : Select the header to retrieve.  If omitted, all headers are retrieved.
                   To avoid saving attached file, enter "nofile:".
           Example: subject:from:date:
    dirname   [in]  : Directory(folder) name where received mails would be saved.
    output [out] : Returns an array of mail contents.
                   Each contents are listed in order of "header, body, attached file".
                   It won't return anything if error occurred.
           Example: output(0) -> To: xxxx@xxxx.xxx
                    output(1) -> From: who@who.com
                    output(2) -> Date: 1998/09/15 12:30:31
                    output(3) -> .....
                    output(4) -> Body: Mail Body
                    output(5) -> File: File Name1
                    output(6) -> File: File Name2
    
    Example:
    outarray = bobj.ReadMail(file,"subject:from:date:",dirname)
    if IsArray(outarray) then	' OK ?
        for each data in outarray
          Response.Write Server.HTMLEncode(data)
        next
    end if
    

  5. Match

    Perl5 Compatible pattern matching method

    match = bobj.Match(regstr,target)
    match [out]  : Returns the result of pattern match.
               0  Did not Match
               1  Matched
         Strings  String itself, if MetaChar() was used.
    regstr [in]  : Regular expression string.  First char must be "/" or"m".
    target [in]  : Target string
    Example:
    input = "abc1234defgい"
    output = bobj.Match("/\d{4}/",input)   ' Returns 1
    output = bobj.Match("/(\d{4})/",input) ' Returns 1234
    

  6. Replace

    Perl5 Compatible String Replace Method

    outstr = bobj.Replace(regstr,target)
    outstr [out]   : Returns the result string
    regstr [in]  : Regular expression string.  First char must be "s".
    target [in]  : Target string
    Example:
    ' enclose all the numbers with <>
    input="123"
    output = bobj.Replace("s/([0-9])/<$1>/g",input)  ' <1><2><3>
    ' enclose numbers in each 3 column with <>
    input="1234567891234"
    output = bobj.Replace("s/(\d{3})/<$1>/g",input)  ' <123><456><789><123>4
    ' Take out the comment from source code written in C (means /* ... */)
    input="a=1; /* this is comment */"
    output=bobj.Replace("s#/\*[^*]*\*+([^/*][^*]*\*+)*/##g",input)  ' a=1;
    

  7. Translate

    Perl5 Compatible String Conversion Method

    outcnt = bobj.Translate(regstr,target,result)
    outcnt [out]   : Returns the number of count conversion proceeded
    regstr [in]  : Regular expression string.  First char must be "tr".
    target [in]  : Target string
    result [out]   : Returns the result string
    Examples:
    count = bobj.Translate("tr/0-9/0-9/k",input,output)
    

  8. Split

    Perl5 Compatible Split Method

    result = bobj.Split(regstr,target[,limit])
    result [out] : Returns the result array of string
    regstr [in]  : Regular expression string.  First char must be "/" or"m".
    target [in]  : Target string
    limit  [in]  : Limit of the array size.  Default is 0(e.g. no limit)
    Examples:
    outarray = bobj.Split("/\s+/i",input,10)
    

  9. FGrep

    Searches for all lines in a given list of files which contains one or more specified pattern. 
    the text file with regular expression and matched with.  Each result stored in an array of string lines, and it returns an array as an output.

    rarray = bobj.FGrep(fname,regstr,limit[,opt])
    rarray [out] : Returns an array of string line including CR/LF code.
                   It won't return anything if error occurred or not match.
    regstr [in]  : Regular expression string.  First char must be "/" or"m".
                   if "" , grep all lines. 
    fname [in]  : Target file name with full path.
    limit [in]  : Limit of the array size to store the result.  Must be more than 1.
    opt   [in]  : option.
                  1 - reverse 
                  2 - line number
    Example:
    rc = bobj.FGrep("g:\exec.txt","/sql/i",10)
    rc = bobj.FGrep("g:\exec.txt","/sql/i",10,2)  ' line number
    rc = bobj.FGrep("g:\exec.txt","",10,1)  ' reverse
    rc = bobj.FGrep("g:\exec.txt","/babaq/",10,1+2)  ' reverse + line number
    if IsArray(rc) then	' Check array
    

  10. FileCheck

    Returns file size, if exists.

    fsize = bobj.FileCheck(fname)
    fsize [out] :
          >=0 : File exists, if fsize more than equals to 0.
          -1  : File does not exist, if fsize equals -1
          -2  : It is a Directory or Folder, if fsize equals -2
    fname [in]  : Target file name with full path.
    

  11. Sort

    Sort the array.   It is also optionally available that the comparative position and string length.

    stime = bobj.Sort(sarray,asdes,soffset,slengh)
    stime [out]     : Returns the time proceeded.
                      If stime was -1 then some parameter error occurred.
    sarray[in,out]  : Target array to be sorted.  Result will be returned in same array.
    asdes [in]      : 0 Ascending sorting   1 Descending sorting
    soffset [in]    : The offset value of the comparative position in string line.
    slength [in]    : String length.  If 0 then all string line becomes target.

  12. ReadDir

    Read directory and returns an array of file name.

    farray = bobj.ReadDir(dirname & option)
    dirname [in]  : Enter the directory name with full path.
    option [in]  :  Option. The option is specified next to " :"
                    s - sort
                    S - descending sort
                    t - sort by file update date
                    T - The file name with the update of the file is returned
                    D - The directory name is not returned
    
    farray  [out] : Returns an array of file name and directory name.
    
    example:
    dir = "c:\data\*.*"
    option = " :St"
    farray = bobj.ReadDir(dir & option)
    option = " :stT"
    farray = bobj.ReadDir(dir & option)
    
    

  13. Space

    Returns a space character code of SJIS(e.g.  X'8140').  This is useful to enter a space in HTML.

    sp = bobj.Space()
    sp [out]  : Space character code
    

  14. IsNum

    Check the strings is Numeric or not.

    rc = bobj.IsNum(str)
    rc [out]   : 0 Not-Numeric  1 Numeric
    sstr [in]  : Target string
    

  15. HAN2ZEN

    Converts a single-space Kata-Kana into double-space Kata-Kana.  It corresponds to the voiced sound(Decoration character ).

    strout = bobj.HAN2ZEN(str)
    strout [out]   : Returns the converted string.
    str [in]  : Strings to be converted.
    

  16. RepTagChar

    Replace the tag for HTML expression.

    outstr = bobj.RepTagChar(instr)
    outstr [out]   : Returns the converted string.
    instr  [in]    : Strings to be converted.
    

  17. BinaryRead

    Read file and returns a binary array of 1 byte.

    barray = bobj.BinaryRead(fname)
    barray [out]   : Returns a binary array
    fname  [in]    : Enter a file name with full path
    Example in ASP:
    barray = bobj.BinaryRead("g:\h.jpg")
    Response.BinaryWrite barray
    

  18. sprintf

    sprintf - Wrapper Method of  C Function

    str = bobj.sprintf(format,val)
    str [out]   : Returns the result of string line.
    format [in] : Format Declaration.
    val [in]    : The numerical value and/or string line. 
    Examples: str = bobj.sprintf("timestamp is %10d",123)

  19. strftime

    strftime - Wrapper Method of  C Function

    str = bobj.strftime(fstr)
    str [out]   : Returns the result of string line.
    fstr [in]   : Format Declaration.
    Examples: TimeStamp = bobj.strftime("timestamp is %Y/%m/%d %X")
    

  20. Debug


    Dump the message that designated to notepad.  Notepad must been opened previously.   If notepad is not opened, nothing appear.  In the case use it with ASP,  the notepad will be executed on the machine where IIS is working.    Be careful that target is not the client machine.

    bobj.Debug(str)
    str [in]   : Enter the message or strings to dump in notepad
    Examples: bobj.Debug(barray)
         bobj.Debug(Array(a,b,c)))
    

  21. StrConv

    The same function as the StrConv function of Visual Basic.  This is the precious method that is not supported in VBScript.

    outstr = bobj.StrConv(instr,type)
    outstr [out]   : Returns the result of string.
    instr  [in]    : Target string to be converted.
    type   [in]    : Set the type of conversion.  Combination available.
    1: Convert to the capital letter of alphabet.
    2: Convert to the small letter of alphabet.
    3: Convert first character to capital letter
    4: Convert all single-space characters(1 byte) to double-space characters(2 byte).
    8: Convert all double-space characters(2 byte) to single-space characters(1 byte).
    16:Convert from HiraGana to KataKana
    32:Convert from KataKana to HiraGana
    Examples: outstr = bobj.StrConv(instr,1)  ' capital letter of alphabet.
    outstr = bobj.StrConv(instr,2+4)  ' the small letter and double-space characters

  22. BinaryWrite

    Write an array of 1 byte into the file.  This is useful when saving an image data into a file.

    wlen = bobj.BinaryWrite(barray,fname[,mode])
    wlen   [out]   : Returns the number of bytes write out.
                     less than 0 is eorror
                     -1 : given array is not 1 byte
                     -3 : file create error
                     -4 : file save error
    barray [in]    : an array of 1 byte
    fname  [in]    : File name with full path
    mode   [in]    : Over write, 0 = New file(default), 1 = Append
    Example in ASP:
    wlen = bobj.BinaryWrite(barray,"g:\h2.jpg")
    wlen = bobj.BinaryWrite(barray,"g:\h2.jpg",1)   ' Append
    

  23. FormSaveAs

    Save the content into a file that uploaded with HTML Form(ENCTYPE="multipart/form-data")
    Example is here.

    wlen = bobj.FormSaveAs(barray,name,fpath)
    wlen   [out]   : Returns the number of bytes write out.
                     less than 0 is eorror
                     -1 : given array is not 1 byte
                     -2 : no name in form
                     -3 : file create error
                     -4 : file save error
    barray [in]    : Contents of the entire form that read by Request.BinaryRead Method.
    name   [in]    : Enter the name which used in <INPUT> tag.
    fpath  [in]    : File name with full path.
    Example in ASP:
    a=Request.TotalBytes
    barray=Request.BinaryRead(a)
    wlen = bobj.FormSaveAs(barray,"Filedata","g:\h3.jpg")
    

  24. FormFileName

    Returns the file name that file uploaded with HTML Form(ENCTYPE="multipart/form-data")

    filename = bobj.FormFileName(barray,name)
    filename   [out]   : Returns a file name that appeared in TYPE=FILE tag.
    barray [in]    : Contents of the entire form that read by Request.BinaryRead Method.
    name   [in]    : Enter the name which used in <INPUT> tag.
    Example in ASP:
    filename = bobj.FormFileName(barray,"Filedata")
    

  25. FormFileSize

    Returns the file size that uploaded with HTML Form(ENCTYPE="multipart/form-data")

    filesize = bobj.FormFileSize(barray,name)
    filesize   [out]   : Returns a file name that appeared in TYPE=FILE tag.
    barray [in]    : Contents of the entire form that read by Request.BinaryRead Method.
    name   [in]    : Enter the name which used in <INPUT> tag.
    Example in ASP:
    filesize = bobj.FormFileSize(barray,"Filedata")
    

  26. Form

    Returns a text content that registered in HTML Form(ENCTYPE="multipart/form-data")

    str = bobj.Form(barray,name)
    str   [out]    : Returns a text where stored in <INPUT> tag.
                     If more than few tags are used, each contents are separated by tab.
    barray [in]    : Contents of the entire form that read by Request.BinaryRead Method.
    name   [in]    : Enter the name which used in <INPUT> tag.
    Example in ASP:
    yname = bobj.Form(barray,"yourname")
    

  27. FormBinary

    Returns a binary array of 1 byte that entered for HTML Form(ENCTYPE="multipart/form-data").   This is useful when write into database.

    sarray = bobj.FormBinary(barray,name)
    sarray   [out]    : Returns a binary array where stored in <INPUT> tag.
    barray [in]    : Contents of the entire form that read by Request.BinaryRead Method.
    name   [in]    : Enter the name which used in <INPUT> tag.
    Example in ASP:
    sarray = bobj.FormBinary(barray,"file1")
    

  28. Execute

    Executes an independent program and receives a standard output.

    rc = bobj.Execute(command,mode,stdout)
    command [in]  : The program name and its parameter(s).
    mode    [in]  : Set mode or time in msec.
                0 - Executes a program and don't wait until it will finish.
                1 - Executes a program and wait until it will finish.
                    Receives an standard output as strings.
                2 - Executes a program and wait until it will finish.
                    Receives an standard output as binary.
      more than 3 - Enter a time in msec.
                    Executes a program and wait until time expires.
                    Receives an standard output, if executed program finished before then time expires.
                    To receive a string output, set Odd number for the time length.
                    To receive a binary output, set Even number for the time length.
                    If you want to use time out for an independent program, try this mode.
    stdout [out]  : Returns the standard output.
    rc [out] : Returns the result in number.
               0  -  Normal completion
              -1  -  Command error.  Check the program name and location..
              -2  -  Time out occured.
    Example:
    rc = bobj.Execute("net view",1,stdout)
    You must use cmd.exe, if you have to execute not Win32 program.
       rc = bobj.Execute("cmd.exe /c c:\lha.exe l basp21.lzh",1,stdout)  ' Windows NT
       rc = bobj.Execute("command.com /c c:\lha.exe l basp21.lzh",1,stdout)  ' Windows 95
    

  29. Kconv

    Converts the string written by certain Kanji code to designated Kanji code.  If cannot determine the Kanji code of source string,  it would be automatically recognized.

    out = bobj.Kconv(instr,outtype[,intype])
    instr   [in]  : Strings to be converted(in case of UNICODE), or byte array.
    outtype [in]  : Enter the Kanji code to be converted.
               0  - Don't convert but returns the type of Kaji code in a number.
               1  - SHIFT JIS
               2  - EUC
               3  - JIS
               4  - UNICODE UCS2
               5  - UNICODE UTF8
    intype  [in]  : If available, enter the correct Kanji code by a number listed below.
               0  - Unknown(default).  Auto Recognition.
               1  - SHIFT JIS
               2  - EUC
               3  - JIS
               4  - UNICODE UCS2
               5  - UNICODE UTF8
    out  [out] : Returns the converted strings(in case of UNICODE), or a byte array.
                 If outtype = 0 then it returns the number of Kanji type.
    Example:
    jisarray = bobj.Kconv("馬場",3)           ' Convert from UNICODE UCS2 to JIS
    outcode = bobj.Kconv(jisarray,4)          ' Convert from JIS to UNICODE UCS2
    
    Caution: Conversion might fail to recognize correct Kanji code, in following case;
    - File is written in SHIFT JIS and single-space of Kana characters
    - File contains very short Kanji sentence only.
    - File is written in UNICODE UTF8
    
    
    

  30. KconvFile

    Converts the file written by certain Kanji code to designated Kanji code.  If cannot determine the existing file's Kanji code,  it would be automatically recognized.

    rc = bobj.KconvFile(infile,outfile,outtype[,intype])
    infile  [in]  : File name to be converted.
    outfile [in]  : File name that written after conversion
    outtype [in]  : Enter the Kanji code to be converted.
               0  - Don't convert but returns the type of Kaji code in a number.
               1  - SHIFT JIS
               2  - EUC
               3  - JIS
               4  - UNICODE UCS2
               5  - UNICODE UTF8
    intype  [in]  : If available, enter the correct Kanji code by a number listed below.
               0  - Unknown(default).  Auto Recognition.
               1  - SHIFT JIS
               2  - EUC
               3  - JIS
               4  - UNICODE UCS2
               5  - UNICODE UTF8
    rc   [out] : Returns the size of the file after conversion.
                 If outtype = 0 then it returns the number of Kanji type.
                 If outtype < 0 then some error was occur; check details below
         -1 : Parameter error
         -2 : File open error before conversion.
         -3 : Size of the file before conversion was 1 or less
         -4 : File mapping error
         -5 : File read error
         -6 : File open error after conversion
         -7 : Memory insufficient
         -8 : File writing error after conversion
    
    Example:
    len = bobj.KconvFile("c:\sjis.txt","c:\euc.txt",2,1)   ' Converts from SHIFT JIS to EUC
    
    Caution: Conversion might fail to recognize correct Kanji code, in following case;
    - File is written in SHIFT JIS and single-space of Kana characters
    - File contains very short Kanji sentence only.
    - File is written in UNICODE UTF8
    
    
    

  31. BinaryConcat

    Merges the byte arraies.

    outarray = bobj.BinaryConcat(inarray1,inarray2)
    inarray1  [in]  : 1st merging array.
    inarray2  [in]  : 2nd merging array.
    outarray  [out] : Merged byte array.
    
    Example:
       outarray = bobj.BinaryConcat(array1,array2)
    

  32. DebugClear

    Clears the notepad window.

    bobj.DebugClear
    
    Example:
    bobj.DebugClear
    

  33. SplitB

    Perl5 Compatible Split procedure for Byte array.  Able to handle null code.

    result = bobj.SplitB(regstr,barray[,limit])
    result [out] : Result in an array of binary array.
    regstr [in]  : Regular expression string.  First char must be "/" or"m".
    barray [in]  : Target binary array.
    limit  [in]  : Max number of arrays used for result.  Default is 0, means no limit.
    
    Example:
    outarray = bobj.SplitB("/\r\n\r\n/",input,2)
    

  34. ByteArray

    Returns byte array from string

    result = bobj.ByteArray(instr[,type])
    result [out] : Result of byte array
    instr  [in]  : String
    type   [in]  : Select ype (0 - 3)
                 0 - Expect SJIS byte array for output(default)
                 1 - Assume HexCode string as an input
                 2 - Expect unicode byte array for output
    
    Example:
    outarray = bobj.ByteArray("000102",1)  ' X'000102'
    

  35. MacthEx

    Extended Pattern Match

    matcharray = bobj.MatchEx(regstr,target[,mode])
    regstr [in]  : Regurar expression string.  First character must "/" or "m"
    target [in]  : Target string
    mode   [in]  : Select mode (0 or 1)
                 0 - Group Match (default)
                 1 - Entire Match
    matcharray [out]   : Returns result in array
               Group Match:
               out(0) : Matched string itself
               out(1) : First part of matched string
               out(2) : Last part of matched string
               out(3) : 1st Group string
               out(4) : 2nd Group string
               out(n) : Nth Group string
               Entire Match:
               out(0) : Matched 1sth String
               out(1) : Matched 2nd String
               out(2) : Matched 3rd String
               out(n) : Matched Nth String
    
    Example:
    marray=Bobj.MatchEx("/<h(\d).+<\/h\1>/ik",b,1) ' Take out all <Hn> Tag from HTML
    
    
    

  36. Counter

    Returns binary array of GIF Counter Image.  This Counter is based on Count Release2.3 (Muhammad A Muquit) but arranged to perform as multithread from original.   It is implemented in BCOUNT.DLL.  There are 8 types of image(dd = a - h) and all images are included in dll as an image resource.

    barray = bobj.Counter(para,ctr)
    para   [in]    : Parameter of Counter. Same as Count Release 2.3
    ctr    [in]    : Amount of Counter
    barray [out]   : Binary Array of Counter Image
    
    Example:
    ========================= ctr.html start ===============
    <HTML><HEAD><TITLE>BASP21 Counter Testing</TITLE></HEAD>
    <BODY BGCOLOR=#FFFFFF>
    <IMG SRC="ctr.asp?p=dd=a&ctr=ctr1"><BR>
    <IMG SRC="ctr.asp?p=dd=b&ctr=ctr2"><BR>
    <IMG SRC="ctr.asp?p=dd=c&ctr=ctr3"><BR>
    <IMG SRC="ctr.asp?p=dd=d&ctr=ctr4"><BR>
    <IMG SRC="ctr.asp?p=dd=e&ctr=ctr5"><BR>
    <IMG SRC="ctr.asp?p=dd=f&ctr=ctr6"><BR>
    <IMG SRC="ctr.asp?p=dd=g,ft=14&ctr=ctr7"><BR>
    <IMG SRC="ctr.asp?p=display=date"><BR>
    <IMG SRC="ctr.asp?p=display=clock"><BR>
    <IMG SRC="ctr.asp?p=dd=h&ctr=ctr8"><BR>
    </BODY></HTML>
    ========================= ctr.html end   ===============
    
    ========================= ctr.asp start  ===============
    <%
    set bobj = Application("bobj")
    p=Request("p")
    ctrname=Request("ctr")
    if len(ctrname) > 0 then
      Application.Lock()
      file=Server.MapPath ("/dir1") & "\" & ctrname & ".txt"
      Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
      On error resume next
      Set inx = FileObject.OpenTextFile(file)
      Count = inx.ReadLine
      inx.Close
      Count = Count + 1
      Set outx = FileObject.CreateTextFile(file,True)
      outx.WriteLine Count
      outx.Close
      Application.UnLock()
    end if
    Response.Expires=0
    Response.Buffer=TRUE
    Response.Clear
    Response.ContentType ="image/gif"
    Response.BinaryWrite bobj.Counter(p,Count)
    Response.End
    %>
    ========================= ctr.asp end     ===============
    
  37. Version
    Return the version string.
    ver = bobj.Version()
    ver [out]   : Version string.(Mmm DD YYYY)。examples:Oct 16 1999。
    
    Example:
    ver = bobj.Version()
    
    
  38. Base64
    BASE64 encoder/decoder.
    outstr = bobj.Base64(instr[,mode])
    instr  [in]   : Character string before converts.
    mode   [in]   : The conversion mode is specified by the figure as follows.
                    0 - default. BASE64 encodes data passed in instr.
                    1 - BASE64 decodes data passed in instr.
                    2 - ISO-2022-JP + BASE64 encodes data passed in instr.
                    3 - ISO-2022-JP + BASE64 decodes data passed in instr.
                    4 - URI encode.
                    5 - URI decode.
                    6 - BASE64 encodes between files.
                    The input file name and the output file name are delimited
                    in the tab and specified for the character string.
                    example: c:\data\input.jpg [TAB] c:\base64\output.txt
                    7 - BASE64 decodes between files.
                    The input file name and the output file name are delimited
                    in the tab and specified for the character string.
                    example: c:\base64\input.txt [TAB] c:\data\output.jpg
    outstr [out]  : the result string.
    
    Example;
    outstr = bobj.Base64("user:pass")
    outstr = bobj.Base64(para,1)
    bobj.Base64 "c:\data\input.jpg" & vbTab "c:\base64\output.txt",6
    
    
  39. GetTempFile
    The temporary file name is returned. When the BASP21 object terminates, the made file is automatically deleted.
    tempfile = bobj.GetTempFile([dir])
    dir    [in]   : Directory name by which file is made. 
                    Default is directory set in TMP or TEMP environment variable.
    tempfile [out]  : Made file name.
    
    example:
    temp1 = bobj.GetTempFile()
    temp2 = bobj.GetTempFile("c:\temp")
    Attention:
    It is not possible to specify the file name for the attached file of the SendMailEx method. 
    
  40. W3get
    The target file of specified URL is preserved in the file. HTTP and the FTP protocol are supported.
    rc = bobj.W3get(para)
    para    [in]   : The parameter is specified as follows:
    	-i input-file : The parameter is input from the file. 
    	-l log-file   : log file name.
    	-d output-directory : output directory.
    	-o output-file      : output file.
    	-j Japanese-character-code : Character-code conversion
    			sjis : SJIS
    			euc  : EUC
    			jis  : JIS
    			ucs2 : UNICODE UCS-2
    			utf8 : UNICODE UTF-8
    	-t timeout    : time-out value. Default is 120 sec. 
    	-p proxy      : HTTP proxy server name.
    	-A user:pass  : HTTP "Authorization: Basic" header.
    	-P user:pass  : HTTP "Proxy-Authorization: Basic" header.
    	-h level      : HTTP header only mode.
                            1: save file.  2: log file.  3: both.
    	-u user-agent : HTTP User-Agent header. Default is Binetx/1.0.
    	-f "firewall-arg" : FTP firewall parameter.
    			"fhost fuser/fpass SITE"
    			"fhost fuser/fpass"
    			"fhost"
    			"fhost OPEN"
    	-a            : FTP ASCII mode
    	-s            : FTP PASV mode
    	url : URL   http:// or ftp://. Specify URL at the end of the parameter. 
    rc      [out]  : The made number of files is returned. 
    
    example:
    ' The file is preserved in the specified directory. 
    rc = bobj.W3get("-d c:\temp http://www.yahoo.co.jp/index.html")
    ' save to temprary file by SJIS code
    temp1 = bobj.GetTempFile()
    rc = bobj.W3get("-o " & temp1 & " -j sjis http://www.yahoo.co.jp/index.html")
    ' ftp
    rc = bobj.W3get("-d c:\temp -j sjis ftp://user:pass@who.com/dir/*.html")
    ' parameter input 
    rc = bobj.W3get("-d c:\temp -i c:\url.txt")
    Content of c:\url.txt :
    -j sjis http://www.yahoo.co.jp/index.html
    -a -d e:\ftp -j sjis ftp://user:pass@who.com/dir/*.html
    http://www.yahoo.co.jp/index.html
    
  41. MidB
    Byte array is taken out by the offset and the number of bytes.
    outarray = bobj.MidB(inarray,offset[,len])
    inarray  [in]   : Byte Array
    offset   [in]   : The beginning taking out position is specified.
                      When the minus is specified, takes out by relativity
                      from a right edge. 
    len      [in]   : The number of bytes taken out is specified. 
                      The default value is taken out to the last minute by 0.
    outarray [out]  : The result is returned by Byte Array. 
    
    
    example:
    outarray = bobj.MidB(b,128)   ' The remainder by which 128 bytes are skipped from head
    outarray = bobj.MidB(b,-128)  ' The last 128 byte data
    outarray = bobj.MidB(b,128,256)   ' 256 bytes by which 128 bytes are skipped from head
    
  42. MatchB
    Perl5 Compatible pattern matching method for Byte Array.
    offset = bobj.MatchB(regstr,barray)
    regstr [in]  : Regular expression string.
    barray [in]  : target Byte Array.
    offset [out]   : Returns the offset value.
        0 Did not Match
        1 or More : Matched relative position + 1
        -1 : pattern error.
    example:
    offset = bobj.MatchB("/\d{4}/",barray)    ' four digits
    offset = bobj.MatchB("/^gif89a/i",bobj.MidB(barray,0,6))  ' gif89a
    
  43. SortMail
    The received mail can be sorted in each directory, be selected, and deleted. The sorting result returns the file name by the array. The path name is not included in the returned file name.
    outArray = bobj.SortMail(dir,header[,option][,filter][,delete])
    dir    [in]  : Directory name of mail file. 
    header [in]  : Header name to be sorted.
                   Specify "" in case of selection and deletion.
                   The generic name character can be used. 
                   example:
                   "From:"    - From Header
                   "Date:"    - Date header
                   "Subject:" - Subject Header
                   "X-Mail*"  - X-Mailer or X-Mail-Agent header
    option [in]  : Options. Default is 0.
                   0 - ascending sort
                   1 - descending sort
                   2 - ignore case
    filter [in]  : Filter option.
                   The filter is specified by header name + condition + character string. 
                   The header name can specify the generic name by "*:".
                   Ignore case.
                   It can be selected whether the header exists when the character string
                   is not specified.                  
                   Body ("Body:") and attached file ("File:") can be specified. 
                   Condition:
                   = : The one which contains the following character string is selected. 
                   ! : The one which does not contain the following character string is selected. 
                   example:
                   "From:=babaq"   - Mail From include "babaq"
                   "To:!hoge"      - Mail To not include "hoge"
                   "Body:=babaq"   - Mail Body include "babaq"
                   "References:="  - include References header
                   "References:!"  - not include References header
                   "X-Mail*:=outlook"   - Mailer is Microsoft OutLook
    delete [in]  : Delete option. 
                   0 - not delete. Default.
                   1 - A corresponding one to the selection condition is deleted. 
    outarray [out]  : The file name sorted (and or selected, deleted )is returned by the array. 
                      Not the array but the character string returns when there are
                      neither an error nor a corresponding mail file.
    
    example:
    outarray = bobj.SortMail(dir,"date:",1)  ' sort by Date:
    ' sort by Date: adn Only mail that "hoge" is included in the From header
    outarray = bobj.SortMail(dir,"date:",0,"from:==hoge")
    ' Only the mail file that "hoge" is included in the From header is deleted. 
    outarray = bobj.SortMail(dir,"",0,"from:==hoge",1)
    ' Only mail with the attached file is deleted. 
    outarray = bobj.SortMail(dir,"",0,"File:=",1)
    ' Only the mail sent with Becky is taken out. 
    outarray = bobj.SortMail(dir,"",0,"X-Mailer:=becky")
    
  44. Sleep
    Sleep at specified time.
    bobj.Sleep sec
    sec    [in]  : Waiting time is specified every second.
    
    example:
    bobj.Sleep 10 ' 10 seconds
    
  45. MD5
    Return Message Digest.
    md5 = bobj.MD5(str[,type])
    str    [in]  : The message character string or the file name is specified.
    type   [in]  : The input type is specified by the numerical value. 
                   0: Character string. Default.
                   1: File.
    md5    [out]  : The message digest of 32 characters is returned. 
    
    example:
    md5 = bobj.MD5("BASP21")  ' 48e1db3b5e94502787d0165dee86afa3
    md5 = bobj.MD5("c:\winnt\system32\basp21.dll",1) ' 684f4bd4f4bb131b40182a98bc2c55a7
    

***** Note *****
The statement of RFC1867(1995.11) announces how to upload file
from Browser to Server, by using HTML,
Following browsers are supporting RFC1867.
To implement file upload with BASP21, you must have at least II3.0 and ASP 1.0.

Example: ============== fileup.htm start ===================================== <HTML><BODY> <FORM ACTION="fileup.asp" ENCTYPE="multipart/form-data" METHOD=POST> Name: <INPUT TYPE=TEXT NAME="yourname"><BR> File1: <INPUT TYPE=file NAME="file1"><BR> File2: <INPUT TYPE=file NAME="file2"><BR> <INPUT TYPE=SUBMIT NAME=UPLOAD> </FORM></BODY></HTML> ============== fileup.htm end ======================================== ============== fileup.asp start ===================================== <% a=Request.TotalBytes b=Request.BinaryRead(a) set obj=server.createobject("basp21") name=obj.Form(b,"yourname") f1=obj.FormFileName(b,"file1") f2=obj.FormFileName(b,"file2") fsize1=obj.FormFileSize(b,"file1") fsize2=obj.FormFileSize(b,"file2") newf1=Mid(f1,InstrRev(f1,"\")+1) newf2=Mid(f2,InstrRev(f2,"\")+1) l1=obj.FormSaveAs(b,"file1","e:\temp\log\" & newf1) l2=obj.FormSaveAs(b,"file2","e:\temp\log\" & newf2) %> <HTML><HEAD><TITLE>File Upload Test</TITLE> <BODY> <H1>Testing</H1> <BR> Dear <%= name %>; Your file has been uploaded<BR> file1= <%= newf1 %><BR> file2= <%= newf2 %><BR> len1= <%= l1 %><BR> len2= <%= l2 %><BR> </BODY></HTML> ============== fileup.asp end ===================================== Those of you, who are using Internet Explorer 3.02, and could not see Browse Button at fileup.htm, you need to install 3.02 File Upload Add-On from Microsoft.

Important Note of BABAQ Free Soft


Home


Copyright 1999-2000 Tatsuo Baba All rights reserved.