Aller au contenu principal

Recherche

Recherche

DataType Mismatch

Commentaires

16 commentaires

  • Avatar
    Joe Sorensen

    Bartender Automation 10.1 latest service release

    Message box states

    Bartender: Error Message #3907

    The following script error occurred:
    OnProcessData(Line 4): : Type mismatch: 'Inches'

    0
  • Avatar
    KM3

    How do you get the data into the script (from the DB)? Make sure the value you get from the DB really is a number (maybe use IsNumeric(Value) to check this as a test). I don't really see how the script executes correctly and gives you the correct result despite the error message...

    Also, you may be able to more easily get the remainder in line 3 and 4 using the Mod operator: https://msdn.microsoft.com/en-us/library/basszbdt(v=vs.84).aspx 

    0
  • Avatar
    Joe Sorensen

    A query prompt accepts a scanned sales order number from paper form, using that query prompt as a WHERE clause, a query return a row/rows of sales order lines which is used as record for tag output.

    Below is a screen shot. The information in the field will be 0 if the object contains no width or no length, i added the " " in the NOT case just to cover bases. So basically if every value should be caught as no non-numerics can exist in the field.

     

    0
  • Avatar
    KM3

    Is there a specific reason this script is located in OnProcessData? I think this may be a problem as BarTender probably tries to execute it at an inconvenient point.

    0
  • Avatar
    Joe Sorensen

    That's just where I thought it went. That is where is saw vbscript on transform tab and thought it went.

    Can you recommend a better way to do this? Used bartender for year but this is my first time scripting anything.

    0
  • Avatar
    KM3

    You can change the data source type of your object to VBScript. You can then also select between 3 different script types. You can also go to File > Document Options (or similar) and add scripts there. However, you may need to change the script a bit to reference the values you need (e.g. to reference a data source named "mydata", you cannot just reference it with "Value" but you need to write Format.NamedSubStrings("mydata").Value)

    0
  • Avatar
    Joe Sorensen

    Just tried that. couldn't figure it out.

    Would it be easier to send you the btw file and see if you could take a peek? I'd be eternally grateful.

    0
  • Avatar
    KM3

    I have another idea. Leave everything the way you had it initially. Remove the double quote marks from the 0 in the first line of your script (so it reads: IF Value <> 0 OR...).

    0
  • Avatar
    Joe Sorensen

    Did that.

    Now getting this error. I don't get why it works perfect (no messages) in print preview but not at actual real print time.

    Here's the code

    IF Value <> 0 OR Value <> " " THEN
    Inches = Value
    Feet = Inches \ 12
    Inches2 = Inches - (Feet * 12)
    Value = Feet & Chr(39) & " " & Inches2 & Chr(34)
    ELSE
    Value = ""
    END IF



    0
  • Avatar
    Joe Sorensen

    should mention the information from the data record is exactly the 3 characters five point five '5.5' (without the quotes) 

     

    and if i enter through both fields it does print fine. But we're trying to make this a scan and grab kind of deal with no prompts.

     

    0
  • Avatar
    KM3

    Ok, I think we're getting closer. Try this:

    1. You have an object containing a data source which is linked to the database. And in the properties of that data source you have your script active in one of the "Transforms" options, correct? Continue only, if yes...
    2. Remove the script and all other transform functionality from the data source.
    3. Give the data source a name, e.g. "db_inches".
    4. Move the entire object out of the way and set its properties to never print.
    5. Create a fresh new object at the first object's former place. Set the data source type to VBScript, select "Event Control Script" as script type.
    6. Open the script editor and in the "OnNewRecord" event, place the script as below.

    dbi = Format.NamedSubStrings("db_inches").Value

    If dbi <> "" Then
       feet = dbi \ 12
       rem = dbi - (feet * 12)
       Value = feet & Chr(39) & " " & rem & Chr(34)
    Else
       Value = ""
    End If

     

    1
  • Avatar
    Joe Sorensen

    You are a genius!

    Not sure why it wasn't working in the Transform Script, but it works as a vbScript object.

    Can i send you some Starbucks?

    0
  • Avatar
    KM3

    Glad I could help - but I'm definitely not a genius; I should have proposed this solution from the very beginning and I might have, had I actually properly tried to understand the problem.

    I don't really know what went wrong but it must have had something to do with how and when the script executed and how/when it stored the enumerated value (or rather: string) - because the script referenced that data source's content itself, it probably backfed the result (feet inches) and so the division didn't work anymore (thus type mismatch, since you cannot do a division on a string). Something like that.

    0
  • Avatar
    Joe Sorensen

    Not sure if you're still following this thread or not, this formula has been amazing so far, but we encountered one issue and i'm not quite sure what is wrong

     

    we had a length of 95.5 inches.

    When run through the formula it calculated 8 feet + negative .5 inches  (prints exactly as 8' -0.5") instead of 7' 11.5"

    any idea why?

    0
  • Avatar
    KM3

    It's because the integer division (dbi \ 12) rounds any fractional component before performing the division. I wasn't aware of that myself either. But the result is clear: 95.5 is rounded to 96, which is then divided by 12, giving exactly 8'. In the next line, you effectively subtract 96 from 95.5, giving -0.5".

    I think you can solve this by disregarding fractional components (decimal values) before doing that division. Like this:

    feet = Int(dbi) \ 12

    I did some minimal testing and that should solve it. However, I noticed that when e.g. using an initial inch value of say 8111.11, the result will be 675' 11.1099999999..7", which is close, but may not what you want to have appear on your label.

    To solve that, round the remainder to your decired number of decimal places, like this:

    rem = dbi - (feet * 12)
    rem = Round(rem, 2)

    0
  • Avatar
    Joe Sorensen

    genius still stands :)
    Longest length we'd have would be like 80' so i think we're good.

     

     

    THANK YOU!

    0

Vous devez vous connecter pour laisser un commentaire.