Bad Length error - Very Urgent

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Garimella
    New Member
    • Jan 2007
    • 9

    Bad Length error - Very Urgent

    Hi

    When I'm trying to write data to a file from a custom variable(contai ns group of string items) it is giving me Runtime Error 59: bad record length.

    Put #1, , ee_rec20 --this is the line which is giving the error

    Kindly respond to this. I've to generate the file in an hour, please.

    Regards,
    Vinay
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by Garimella
    Hi

    When I'm trying to write data to a file from a custom variable(contai ns group of string items) it is giving me Runtime Error 59: bad record length.

    Put #1, , ee_rec20 --this is the line which is giving the error

    Kindly respond to this. I've to generate the file in an hour, please.
    Sorry if it's too late now, but can you show us the definition of ee_rec20?
    And how is the file opened - for Binary or Random? Posting the Open statement would probably help.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Also, have you read the doco on this error?

      Bad record length (Error 59)

      The length of a recordvariable in a Get or Put statement must be the length specified in its corresponding Open statement. This error has the following causes and solutions:
      • The record variable's length differs from the length specified in the corresponding Open statement.
        Make sure the sum of the sizes of fixed-lengthvariables in theuser-defined type defining the record variable's type is the same as the value stated in the Open statement's Len clause. In the following example, assume RecVar is a variable of the appropriate type. You can use the Len function to specify the length, as follows:
        Code:
        Open MyFile As #1 Len = Len(RecVar)
      • The variable in a Put statement is (or includes) a variable-length string.
        Because a 2-byte descriptor is always added to a variable-length string placed in a random access file with Put, the variable-length string must be at least 2 characters shorter than the record length specified in the Len clause of the Open statement.

      • The variable in a Put statement is (or includes) a Variant.
        Like variable-length strings,Variant data types also require a 2-byte descriptor. Variants containing variable-length strings require a 4-byte descriptor. Therefore, for variable-length strings in a Variant, the string must be at least 4 bytes shorter than the record length specified in the Len clause.

      Comment

      • Garimella
        New Member
        • Jan 2007
        • 9

        #4
        Hi Killer42,

        Thank you very much for the help. I solved it yesterday itself. Yes it was because of the definition of length. It was declared as 600 characters whereas the final output has 619 characters. That's not the end of the story.. i've one more issue. Now few records are having lot of spaces inthe front because of which the file looks unorganized. can you please help me. it's looking like this.
        Code:
                                           000034330000 ........................(this is having lot of spaces before...)
        090090000 txtfior....
        090090000 txtfior....
        090090000 txtfior....
                                           000034330000 ........................
        Last edited by Killer42; Feb 21 '07, 08:11 PM. Reason: Use CODE tags to preserve formatting.

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Glad to hear you resolved the first problem.

          As for the spaces, I think we'd need to see the code which wrote that data. Quick question, though - are you sure you don't just have those spaces in the variable that you're writing?

          Comment

          Working...