Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Optional parameters about the function
#1
I have encountered a strange problem, the same problem in the win7 64-bit English version and the Chinese version system.

I hope the developer can verify and fix it, the code and the action demo are here

http://www.quickmacros.com/forum/showthr...7#pid33407
#2
Win has a problem when there are optional function arguments the function errors. He is not able to run most functions that have optional arguments or if the function works the optional variable is empty
#3
If you need me to cooperate, you can use teamvievwer to connect to my computer to check the situation.  Smile
#4
Which code does not work? I tested this, it works as expected.

Code:
Copy      Help
str s ss sss
int i t
s="this is a test"
ss="for Win"
i=4
t=132
sub.TestForWin(s sss ss i t)
out sss
#sub TestForWin
function ~s1 ~&result [~s2] [ii] [tt]
result.format("%s %i %s %i" s1 ii s2 tt)
ret

The code without spaces between parameters is incorrect.
#5
- never mind -
#6
The bug is that QM does not throw a syntax error when used code like this:
Code:
Copy      Help
[~s2][int'ii][int'tt]
#7
it's very strange any function that has optional function arguments doesn't work for him or only partially works. i cannot reproduce his problem either.They work for me but not him.
Another example

,case LBN_DBLCLK<<16|4
,LB_SelectedItem(lParam _s)
,mes F"selected {_s}"
 
see here as well 
http://www.quickmacros.com/forum/showthr...0#pid33350

 don't work or only partially work for him.
#8
Ah ok, I edited my post.
(sorry).
#9
@kevin

I also just found out that if there is a space between the parameters, it can run successfully.

function# hwnd [ARRAY(int)&ai] [ARRAY(str)&as]


Function LB_GetSelectedItems
Code:
Copy      Help
;/
function# hwnd [ARRAY(int)&ai] [ARRAY(str)&as]

;Gets selected items in a multisel listbox control.
;Returns number of selected items.

;hwnd - control handle.
;ai - array variable that receives indices of selected items. Optional, can be 0.
;as - array variable that receives text of selected items. Optional, can be 0.

;REMARKS
;The control must belong to current process. Use eg in dialog procedures.


if(&ai) ai=0
;if(&as) as=0

int i n
n=SendMessage(hwnd LB_GETSELCOUNT 0 0); if(n<1) ret
if &ai or &as
,ARRAY(int) _ai; if(!&ai) &ai=_ai
,ai.create(n)
,n=SendMessage(hwnd LB_GETSELITEMS n &ai[0]); if(n<0) n=0
,if(n!ai.len) ai.redim(n)
,if &as
,,as.create(n)
,,for(i 0 n) LB_GetItemText(hwnd ai[i] as[i])
ret n

http://www.quickmacros.com/forum/showthr...0#pid33350
This problem is still not solved
#10
very strange i didn't touch the function code only copied and pasted. I just checked it has a space on my qm file. Maybe in that case the spaces didn't transfer over

ok i did find the reason  for that particular one
seems if you preview a post before submitting some spaces are removed

example
post code directly

Function LB_GetSelectedItems
Code:
Copy      Help
;/
function# hwnd [ARRAY(int)&ai] [ARRAY(str)&as]

;Gets selected items in a multisel listbox control.
;Returns number of selected items.

;hwnd - control handle.
;ai - array variable that receives indices of selected items. Optional, can be 0.
;as - array variable that receives text of selected items. Optional, can be 0.

;REMARKS
;The control must belong to current process. Use eg in dialog procedures.


if(&ai) ai=0
if(&as) as=0

int i n
n=SendMessage(hwnd LB_GETSELCOUNT 0 0); if(n<1) ret
if &ai or &as
,ARRAY(int) _ai; if(!&ai) &ai=_ai
,ai.create(n)
,n=SendMessage(hwnd LB_GETSELITEMS n &ai[0]); if(n<0) n=0
,if(n!ai.len) ai.redim(n)
,if &as
,,as.create(n)
,,for(i 0 n) LB_GetItemText(hwnd ai[i] as[i])
ret n

and now code previewed then submitted

Function LB_GetSelectedItems
Code:
Copy      Help
;/
function# hwnd [ARRAY(int)&ai][ARRAY(str)&as]

;Gets selected items in a multisel listbox control.
;Returns number of selected items.

;hwnd - control handle.
;ai - array variable that receives indices of selected items. Optional, can be 0.
;as - array variable that receives text of selected items. Optional, can be 0.

;REMARKS
;The control must belong to current process. Use eg in dialog procedures.


if(&ai) ai=0
if(&as) as=0

int i n
n=SendMessage(hwnd LB_GETSELCOUNT 0 0); if(n<1) ret
if &ai or &as
,ARRAY(int) _ai; if(!&ai) &ai=_ai
,ai.create(n)
,n=SendMessage(hwnd LB_GETSELITEMS n &ai[0]); if(n<0) n=0
,if(n!ai.len) ai.redim(n)
,if &as
,,as.create(n)
,,for(i 0 n) LB_GetItemText(hwnd ai[i] as[i])
ret n

there is a bug in the forum preview code it removes spaces.
#11
So that is what it is , I really admire your seriousness  Smile
#12
Confirmed.
It is a bug in forum software. Probably i will not be able to fix it. But now you know how to live with it.
#13
Function Function19
Code:
Copy      Help
;/
function# [a] [b]

;Surprise! I installed the new version of the editor plugin, and the bug is fixed.
#14
That's good news thanks Gintaras
#15
thanks Gintaras


Forum Jump:


Users browsing this thread: 5 Guest(s)