Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error mystery

Status
Not open for further replies.

StewartUK

Programmer
Feb 19, 2001
860
GB
My application, built in VFP 9 SP2, recently threw a Function argument value, type, or count is invalid error on the line
Code:
inval1 = INKEY(0.06,[HM])
which is in the Click method of a command button. Can anyone suggest how that might have occurred?

The variable inval1 wasn't declared in the method, but I've searched the application (using the Code References tool) for that string and it only came back with results from this Click method.

By the way, that line is taken from Tek-Tips faq1254-5072.

Thanks,

Stewart
 
Well as I say it wasn't declared, although I have now done that but I hadn't assigned a dummy value to it. I'll try that as well.

I can't get my head around it though. I can't see how the line could trigger that error.

Stewart
 
Hi Mike, hope you're well.

Yes, it works for me too and I can't reproduce it. I've never had an error on this line before and don't understand how it could have happened. Very frustrating.

The production code is:
Code:
WITH .cmdCancelPrint
    .Enabled    = .T.
    .Refresh()
ENDWITH
.
.
.
SCAN && AllAllos
**************************************** THIS SECTION OF CODE ADAPTED FROM TEK-TIPS FAQ faq1254-5072. It allows for a Stop button to interrupt the scan.
DOEVENTS
WITH .cmdCancelPrint
  .Enabled    = .T.
  .Refresh()
ENDWITH
INKEY(0.001)
lnSeconds = SECONDS()
DO WHILE .T.
  [COLOR=red]inval1 = INKEY(0.06,[HM])[/color]
  IF SECONDS() > lnSeconds + 2.5
    EXIT
  ENDIF
  IF inval1 = 151 AND .lCancelButton
    .lQueryExit = .T.
    EXIT
  ENDIF
ENDDO
WITH .cmdCancelPrint
  .Enabled = .F.
  .Refresh()
ENDWITH
INKEY(0.001)
IF .lQueryExit
    MESSAGEBOX("Printing cancelled", Mb_Ok+Mb_InfoIcon, "Foundation income list(s)")
    EXIT
ELSE

Stewart
 
Any chance someone defined HM as a constant somewhere that's included here?

Tamar
 
I think Tamar has the reason, make it inval1 = INKEY(0.06,'HM') and if HM is a constant it can't hurt anymore. On the other side I tried different constant values for a constant HM and couldn't fine one that would be the culprit. With something very unusual like #DEFINE HM ],1,2,3,[ you'll get a too many arguments error.

Bye, Olaf.
 
Thanks for everyone's help. I've now defined the variable inval1 as LOCAL and changed to single quote marks around the HM.

As an aside, I hadn't realised that there is ever any difference between ' ' & [ ] marks in VFP. Learn something new every day!

Stewart
 
As [] can be used for array[index] constants are used within [], while they are not substututed within string literals delimited with " or '.
 
Stewart said:
I've never had an error on this line before and don't understand how it could have happened.

If I understand you correctly, the code was working as expected up to a point in time.

Without backtracking to understand what code changes, if any, were made at that point in time, the mystery remains.

The FAQ will be changed in the light of this thread by declaring the variable and using single quotes.

The FAQ was written in '04 but I've personally used the code before and since without incident and would have modified the FAQ had it been necessary.

Thanks for sharing the problem. [smile]

FAQ184-2483​
Chris [pc2]
PDFcommander.com
motrac.co.uk
 
Chris,

Your understanding is correct. I incorporated your FAQ into my application some years ago (thanks :)) and like you have had no problem until now.

Stewart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top