dll array in asp

Results 1 to 2 of 2

Thread: dll array in asp

  1. #1
    Join Date
    Dec 1969

    Default dll array in asp

    I have a function in a dll that returns an array of Strings.<BR>this is the way it is defined: file_variables(10) As String.<BR>and this is the way i return it : read_file = file_variables (where read_file is the function name)<BR>Now, I need to to capture the value returned by this function in asp.<BR><BR>Snippet of my asp code<BR>----------------------------<BR>dim val <BR>val = obj.read_file()<BR>Response.Write Ubound(val)<BR>for i=0 to UBound(val) <BR>response.write val(i)<BR>next<BR>----------------------------<BR>the UBound gives 10, but response.write val(i) gives "type mismatch" error.<BR>Also when I write isArray(val) I get &#039;TRUE&#039;.<BR><BR>The function in my dll is as follows:<BR>----------------------------------------<BR>Public Function read_file()<BR>Dim str_line As String, pos As Integer, file_counter As Integer, file_variables(10) As String<BR>Set objFSO = CreateObject("Scripting.FileSystemObject")<BR>If objFSO.FileExists(App.Path + "sso_setup_config.txt") Then<BR><BR>On Error GoTo errorhandler<BR>Set objTextStream = objFSO.OpenTextFile(App.Path + "sso_setup_config.txt", 1)<BR>Do While Not objTextStream.atendofstream<BR>str_line = objTextStream.readline<BR>pos = InStr(str_line, "=")<BR>file_variables(file_counter) = (Mid(str_line, pos + 2, Len(str_line)))<BR>file_counter = file_counter + 1<BR>Loop<BR>Else<BR>read_file = "file"<BR>End If<BR>read_file = file_variables<BR>Exit Function<BR><BR>errorhandler:<BR>read_file = "ERROR in read_file: " + Err.Description<BR>Exit Function<BR><BR>End Function<BR>----------------------------------------<BR>

  2. #2
    Join Date
    Dec 1969

    Default You need to return a VARIANT.

    You declare file_variables as a 11-element array of strings. It should be declared as a VARIANT. You can then re-dim it to length 11:<BR><BR>Dim file_variables as variant<BR>ReDim file_variables(10)<BR><BR>Also, the type of the return element of the function should be a variant:<BR><BR>Public Function read_file() as variant<BR><BR>Then, when you return the array, it&#039;ll like it in ASP.<BR><BR>Craig.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts