In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Zoot wrote: Because the second number in the function declaration is the number of parameters expected to be passed: 1. MyFunc FUNC return bytes, minimum number of parameters, maximum number of parameters If you are expecting to pass different numbers of bytes (sometimes a word, sometimes a word and a byte, etc), then you either need to parse and decide what to do based on __PARAMCNT (in your function itself): MyFunc FUNC 2, 1, 3 FUNC MyFunc IF __PARAMCNT = 1 THEN ' only one byte? clear MSB of wparam12 and clear param3 __PARAM2 = 0 __PARAM3 = 0 ELSEIF __PARAMCNT = 2 THEN __PARAM3 = 0 ENDIF tmpW1 = __WPARAM12 tmpB3 = __PARAM3 ' do stuff RETURN tmpW1 ENDFUNC --- OR ---- you need to force the function call to "promote" values to Words, even if you pass a byte, e.g. MyFunc FUNC 2, 3, 3, Word, Byte would be a function that returns two bytes (__WPARAM12) and expects 3 bytes as a Word and a Byte. The cool thing is even if your value for the Word parameter is <256, SX/B will clear the upper byte of the parameter word. So.... FUNC MyFunc tmpW1 = __WPARAM12 tmpB3 = __PARAM3 ' do some stuff RETURN tmpW1 ENDFUNC If I do this: someWord = MyFunc, 1, 10 then param1 = 1 param2 = 0 param3 = 10 If I do this: someWord = MyFunc, 2000, 10 then param1 = 2000 & $FF param2 = 2000 >> 8 param3 = 10 ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=402275#m402279 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)