Prev: Activate the first input element
Next: One Shot Timers
From: dpb on 30 Jun 2010 14:58 Claire wrote: ....[top posting repaired...don't do that; hard follow conversation make]... > "Claire" <replyto(a)fra> wrote in message > news:Ofp6qZ%23FLHA.1996(a)TK2MSFTNGP06.phx.gbl... >> Hello, >> I have just came across this problem: >> This line of code: >> If rlineGetDevCaps(l) = True And LineID(l) = >> Val(Mid(sSelectLines, i + 4, k - i)) Then .... >> This line of code works properly in development stage but when compiled it >> does not. .... > Thank you all for all that lively discussion. > For all people interested in more details please find the > corresponding code. > However, it may not be simple for you fo trace it. The following code > uses TAPI interaction with the modem (TAPI device) > ============================ > Declare Function lineGetDevCaps ... (ByVal hLineApp As Long, > ..., lpLineDevCaps As LINEDEVCAPS) As Long And, as surmised, there's a problem -- lineGetDevCaps returns a Long, not a Boolean SDK says in part... "Return Values Returns zero if the request succeeds or a negative error number if an error occurs. Possible return values are: ...[sizable list of named constants elided]... ...." Fix the logical comparison to the proper choice(s) and I'll wager all will be well... If you don't care what the error is then it should be If rlineGetDevCaps(l) <> 0 ... --
From: Claire on 30 Jun 2010 15:50 "dpb" <none(a)non.net> wrote in message news:i0g49n$j4a$1(a)news.eternal-september.org... > Claire wrote: > > ...[top posting repaired...don't do that; hard follow conversation > make]... > >> "Claire" <replyto(a)fra> wrote in message >> news:Ofp6qZ%23FLHA.1996(a)TK2MSFTNGP06.phx.gbl... >>> Hello, >>> I have just came across this problem: >>> This line of code: >>> If rlineGetDevCaps(l) = True And LineID(l) = Val(Mid(sSelectLines, i + >>> 4, k - i)) Then > ... >>> This line of code works properly in development stage but when compiled >>> it does not. > ... > > Thank you all for all that lively discussion. >> For all people interested in more details please find the >> corresponding code. >> However, it may not be simple for you fo trace it. The following code >> uses TAPI interaction with the modem (TAPI device) > > > ============================ > > Declare Function lineGetDevCaps ... (ByVal hLineApp As Long, > > ..., lpLineDevCaps As LINEDEVCAPS) As Long > > And, as surmised, there's a problem -- > > lineGetDevCaps returns a Long, not a Boolean > > SDK says in part... > > "Return Values > Returns zero if the request succeeds or a negative error number if an > error occurs. Possible return values are: > ...[sizable list of named constants elided]... > ..." > > Fix the logical comparison to the proper choice(s) and I'll wager all will > be well... > > If you don't care what the error is then it should be > > If rlineGetDevCaps(l) <> 0 ... > > -- Bad, bad, bad. lineGetDevCaps () is API function used by my function called: rlineGetDevCaps () I thought until now I can create my own function as I like it and I do not need to consult SDK about that. Please be careful next time. Claire
From: Ulrich Korndoerfer on 30 Jun 2010 16:25 Hi Karl, Karl E. Peterson schrieb: > After serious thinking Ulrich Korndoerfer wrote : >> So VB is free to compute CondA first or CondB. VB does not guarantuee >> any sequence. Especially when compiling to native code, the compiler >> may shuffle execution sequences around for optimizing purposes. > > Beat me to it. NEVER use both a function and the result of that > function within the same IF test. You're just *asking* to be spanked! > Yes, that in general would be wise to avoid hazzles. In the case of the OP CondB is a function call whose result delivers CondB *and* sets a ByRef variable to a value on which the function call that delivers CondA as result depends on. So she has to take measures that CondB is evaluated first. Now CondA And CondB is just an expression, like 1 + 2 or CondA + CondB or whatever. VB does not guarantee a certain sequence when evaluating expressions, *except* when braces on subexpressions are used. Braces are respected by VB and with braces one can control the sequence of execution: braced subexpressions are evaluated as a whole. Unfortunately with CondA And CondB there is no subexpresssion one could put braces around. But one could do tricks: CondA And (CondB And True) should result in CondB evaluated before CondA. -- Ulrich Korndoerfer VB tips, helpers, solutions -> http://www.prosource.de/Downloads/ MS Newsgruppen Alternativen -> http://www.prosource.de/ms-ng-umzug.html
From: dpb on 30 Jun 2010 17:00 Claire wrote: > "dpb" <none(a)non.net> wrote in message > news:i0g49n$j4a$1(a)news.eternal-september.org... >> Claire wrote: >> >> ...[top posting repaired...don't do that; hard follow conversation >> make]... >> .... > lineGetDevCaps () is API function used by my function called: > rlineGetDevCaps () > I thought until now I can create my own function as I like it and I do not > need to consult SDK about that. .... OK, sorry, I did, in fact, overlook the rLine... It looks ok in that it is declared Boolean except... 1) This is a nit but I'd initialize rlineGetDevCaps = False on entry just as good practice. It isn't the problem; not saying it is... 2) Second nit--since it does return a Boolean, the test If rlineGetDevCaps(l) = True And LineID(l) = ... might better be written as If rlineGetDevCaps(l) And LineID(l) = ... Again, it isn't the actual problem but still a Boolean is a logical already. 2) I don't see where lineID() is returned anywhere??? Ergo, it's a Global array? I (as others noted) don't like the side effects that way and it looks like there are paths that it doesn't get updated in the function? Any possibility there's a logic flaw there somehow? At a minimum I'd return a used value in the argument list I believe and at least reconsider refactoring the function. --
From: Claire on 30 Jun 2010 22:55
"dpb" <none(a)non.net> wrote in message news:i0gbdm$uah$1(a)news.eternal-september.org... > Claire wrote: >> "dpb" <none(a)non.net> wrote in message >> news:i0g49n$j4a$1(a)news.eternal-september.org... >>> Claire wrote: >>> >>> ...[top posting repaired...don't do that; hard follow conversation >>> make]... >>> > ... > >> lineGetDevCaps () is API function used by my function called: >> rlineGetDevCaps () >> I thought until now I can create my own function as I like it and I do >> not need to consult SDK about that. > ... > > OK, sorry, I did, in fact, overlook the rLine... > > It looks ok in that it is declared Boolean except... > > 1) This is a nit but I'd initialize rlineGetDevCaps = False on entry just > as good practice. It isn't the problem; not saying it is... > > 2) Second nit--since it does return a Boolean, the test > > If rlineGetDevCaps(l) = True And LineID(l) = ... > > might better be written as > > If rlineGetDevCaps(l) And LineID(l) = ... > > Again, it isn't the actual problem but still a Boolean is a logical > already. > > 2) I don't see where lineID() is returned anywhere??? Ergo, it's a > Global array? I (as others noted) don't like the side effects that way > and it looks like there are paths that it doesn't get updated in the > function? Any possibility there's a logic flaw there somehow? > > At a minimum I'd return a used value in the argument list I believe and at > least reconsider refactoring the function. > > -- Yes, LineID() is a global array and if you have a closer look at the rlineGetDevCaps () routine you'd find it in there. For me Ulrich Korndoerfer's reply sounds reasonable. Thanks, Claire |