Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inconsistent Results
#1
I am getting the error "0x80020005, Type mismatch" but its not consistent. Sometimes the macro works, sometimes I get the message.

I dont even know which line is in error Tongue
#2
What is the code? This error may occur for example when working with OLE types. Example:

DATE d="444444"

QM internally uses standard conversion functions, and, if function fails, it returns error code, and QM just displays error code and associated message.

To show last error line, press F2. To show automatically, set it in Options.
#3
CURRENCY a
CURRENCY b

str c="AMOUNT (100,000.00)"
str d=100000
b=d

c.trim("AMOUNT (")
c.trim (")")
a=c

if a <= b
mes "ok"
else
mes "not ok"


What I am trying to do is get the value of "c" and compare it to the value of "d."

If I use wait 5 before the if statement, seems to work.

Is there also a way to find out the line where the error occurs?
#4
There is one weak place:

c.trim("AMOUNT (")

Here "AMOUNT (" is set of characters that are trimmed. Now this succeeds, and it would also succeed if c would be eg "TNU 100,000.00A". But if c sometimes has different format, this statement may fail to extract the number. Then c would not be numeric, and a=c would throw "...Type mismatch" error.

Regular expressions are ideal to extract numbers and other complex substrings. Try this:

Code:
Copy      Help
CURRENCY a b="100000"
str c="AMOUNT (100,000.00)"

if(findrx(c "\d+(,\d+)*\.\d\d" 0 2 c)<0) out "number not found"; ret
a=c

mes iif(a<=b "ok" "not ok")

To show last error line, press F2. To show automatically, set it in Options.
#5
Is it possible just to extract the numbers, which is always there, from a string?
#6
Above example extracts number in format xxx.xx or xxx,xxx.xx , etc. Do you have problems with it?
#7
I haven't tried it yet. But what if the numbers does not have a comma or period?

I thought that maybe there's a way to remove any alpha and/or punctuation from a string, leaving the numbers.
#8
This regular expression extracts decimal numbers in any format. Positive, negative, with or without commas, integers or with decimal point, with or without positive or negative exponent.

Code:
Copy      Help
CURRENCY a b="100000"
[color=blue]str [/color]c="AMOUNT (100,000.00)"

[color=blue]str [/color]rx="[+-]? *\d+(,\d+)*(\.\d+)?([Ee][+-]\d+)?" [color=green];;regexp to extract numbers[/color]

[color=blue]if[/color]([color=blue]findrx[/color](c rx 0 0 c)<0) [color=blue]out [/color]"number not found"; [color=blue]ret[/color]
[color=blue]out [/color]c
a=c

[color=blue]mes iif[/color](a<=b "ok" "not ok")
#9
WORKS LIKE A CHARM!

TYVM :lol:


Forum Jump:


Users browsing this thread: 4 Guest(s)