Jump to content
Sign in to follow this  
darkshadow791

Default function paramaters not working?

Recommended Posts

darkshadow791

I have the following code that is part of a notepad-like program:

Func Save($printtest = 1) ;all save's must write to $SaveBuffer as well as saving.
    If Not $printtest = 1 Then
        If Not $Save = "" Then
            $box = MsgBox(4, "Must save before printing.", "You must save before printing. Do you wish to save now?")
            If $box == 6 Then ;yes
                $filetoopen = FileOpen($Save,2)
                $SaveBuffer = GUICtrlRead($Edit)
                FileWrite($Save, $SaveBuffer)
                _FilePrint($Save)
            Else
                ;they don't want to save so they can't print!
            EndIf
        Else
            $box = MsgBox(4, "Must save before printing.", "You must save before printing. Do you wish to save now?")
            If $box == 6 Then ;yes
                $Save = FileSaveDialog("Save...",@ScriptDir & "Notes\","All files (*.*)", 16)
                If Not @error Then $SaveBuffer = GUICtrlRead($Edit)
                FileWrite($Save, $SaveBuffer)
                _FilePrint($Save)
            EndIf
        EndIf
    Else ;don't print
        If Not $Save = "" Then
            $filetoopen = FileOpen($Save,2)
            $SaveBuffer = GUICtrlRead($Edit)
            FileWrite($Save, $SaveBuffer)
        Else
            $Save = FileSaveDialog("Save...",@ScriptDir & "Notes\","All files (*.*)", 16)
            If Not @error Then $SaveBuffer = GUICtrlRead($Edit)
            FileWrite($Save, $SaveBuffer)
        EndIf
    EndIf
EndFunc

Func Print()
    Save(0)
EndFunc
oÝ÷ Øz0z÷«"­Áè«uê뢹²Æ zÌ!zr-¯+hq©eI«ÞÂ+aZ­©µêì"Ü(®Kw°éÈq©e>¸§´ýÆ¥)àÛâi«­¢+ØÀÌØí5}¥±ôU%
Ñɱ
ÉÑ5¹Ô ÅÕ½Ðí¥±ÅÕ½Ðì¤(ÀÌØí¥±}MÙôU%
Ñɱ
ÉÑ5¹Õ¥Ñ´ ÅÕ½ÐíMÙÅÕ½Ðì°ÀÌØí5}¥±¤)U%
ÑɱMÑ=¹Ù¹Ð ´Ä°ÅÕ½ÐíMÙÅÕ½Ðì¤((ÀÌØí5}¥ÐôU%
Ñɱ
ÉÑ5¹Ô ÅÕ½Ðí¥ÐÅÕ½Ðì¤(ÀÌØí¥±}AÉ¥¹ÐôU%
Ñɱ
ÉÑ5¹Õ¥Ñ´ ÅÕ½ÐíAÉ¥¹ÐÅÕ½Ðì°ÀÌØí5}¥±¤)U%
ÑɱMÑ=¹Ù¹Ð ´Ä°ÅÕ½ÐíAÉ¥¹ÐÅÕ½Ðì¤

Any suggestions? I've also tried using True/False instead of numbers, but that doesn't seem to work either.

Note: I know I can easily just copy the function over to fix the problem, but I want to know why it's giving me this error.

Share this post


Link to post
Share on other sites
MrCreatoR

I think this is a bug, i have run into it a while ago, but had no time to check it realy... here is my post in the bugs report forum - http://www.autoitscript.com/forum/index.php?showtopic=44569.


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites
Jos

I think this is a bug, i have run into it a while ago, but had no time to check it realy... here is my post in the bugs report forum - http://www.autoitscript.com/forum/index.php?showtopic=44569.

NOBUG http://www.autoitscript.com/forum/index.ph...st&p=175225

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
MrCreatoR

So function parameters just don't work with events or hotkeys? :/

Correct ...

This is mentioned in the help file? if not, then i think it should be.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites
Jos

This is mentioned in the help file?

Maybe look first and then post ?

The called function can not be given parameters. They will be ignored.

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
MHz

I looked through onevent and gui*onevent and it says nothing about parameters being ignored though.

Look at the help file for GUICtrlSetOnEvent.

Do you see a parameter where you can pass a parameter to the called function? I see Not.

Does the help file tell you that a parameter is supported in the called function from GUICtrlSetOnEvent? I see Not.

If the help file shows that parameter passing is not available for the function and the help file does not state that it can be done, then hey, it cannot. If it is not there, then dreaming that it could exist, does not mean it should exist. :shocked:

Share this post


Link to post
Share on other sites
darkshadow791

I understand it can't send parameters but there is a difference between not sending parameters and not being able to support default parameters.

Both of the following call a function without sending a parameter:

FunctionName()
GuiCtrlSetOnEvent($guithing, "FunctionName")

But that doesn't mean that parameters made by the function's declaration should be ignored, just because it doesn't send a parameter in the call.

Just my $0.02

Edited by darkshadow791

Share this post


Link to post
Share on other sites
MHz

Well, the help file still says nothing about your idea so you dreamed it. The inverse could be true also, yes? So, what is your point in the sense of reality?

If you say default parameters should work, then why does not a normal parameter then if it was standard effect to support parameters.

GuiCtrlSetOnEvent($guithing, "FunctionName")

Func FunctionName($parameter)
    MsgBox(0, '', $parameter)
EndFunc

The difference between a default parameter and sending a parameter is choosing whether you will send a parameter. You have no choice to start with GuiCtrlSetOnEvent. :shocked:

Keep ya $0.02

Share this post


Link to post
Share on other sites
darkshadow791

You're completely missing my point... In every other non-scripting programming language (c, c++, java, etc) there is the ability to create multiple functions with a different number of parameters... It's called over-riding functions. In AI there is no such option, there is only the option to create "Default" parameters. Theoretically, when you call a function in autoit that has parameters those parameters must be supplied either via the call or the instantiation of the function. If it is supplied via the function, AI should theoretically use the supplied parameters if the call does not supply it's own. Therefore, any time you call the function and do not use parameters, the function should supply it's own set of default parameters. Using GuiCtrlSetOnEvent, you do not have the option of supplying parameters, you only can supply the string name of the function to call. Because of this, it should use it's default parameters unless otherwise noted. The help file says no such thing about not supporting this, so it should work. I don't see how I dreamed this up.

Edit: And to answer your question.

If you say default parameters should work, then why does not a normal parameter then if it was standard effect to support parameters.

GuiCtrlSetOnEvent($guithing, "FunctionName")

Func FunctionName($parameter)
    MsgBox(0, '', $parameter)
EndFunc
The reason this wouldn't work is because you are forced to supply a parameter with the call, and you do not have the option of supplying a parameter. This could never work in the context you have presented it.

If you still don't get it:

My theory:

FunctionName() ;note 1

Func FunctionName($string = "blah") ;note 2

;do something here

EndFunc

Calling FunctionName (note 1) without supplying parameters (there is nothing inside the () ) will call the function FunctionName. When it see's ($string = "blah"), AI realizes that you did not supply any parameters on the call, so it should use this parameter instead, because of the way AI is built. The theory should be the same for any other use of the call of FunctionName, unless otherwise noted (like in HotKeySet).

This really isn't that confusing of an idea and I don't see why you're being so rude about it.

Edited by darkshadow791

Share this post


Link to post
Share on other sites
MHz

You're completely missing my point...

No, you miss the point by what is stated to you. It is not mentioned in the help to exist. Of all the languages out there, or let's narrow it down to basic languages, which support your theory?

I am calling a spade a spade. If you think that I am rude considering that you cannot accept that if something is not mentioned to exist in the help file, then it should exist, is utterly absurd.

Share this post


Link to post
Share on other sites
evilertoaster

What doesn't exist is explictly stating that it does not support this for the gui set on event. This has been discused before.... it's not a bug with autoit, it's just a lack of explicit documentation for somthing that has previously been assumed to be 'common knowledge'

ejoc posted this previously and the work around for it

http://www.autoitscript.com/forum/index.php?showtopic=9847

Alot of confusion would probably be cleared up by saying somthing in the help file like-

"The called function can not be given parameters. They will be ignored (as will the defualt paramaters of the function)" instead of just "The called function can not be given parameters. They will be ignored."

as well as putting such a note on GUICtrlSetOnEvent ()

Perhaps the actual only error then is that the paramaters are not 'ignored' (since it kinda tries to use them)

Edited by evilertoaster

Share this post


Link to post
Share on other sites
MHz

*sigh* You really don't understand this do you?

Fine. Specifically what in the help file are you saying does not exist?

Look, what event driven language supports your fuckin' theory?

That goes for you as wel, evilertoaster!

I have seen 5 year old kids whine less then this over the same kinder useless shit. Who wants to read comments over shit that does not exist, just because you want to score from your stupid topic through a thoughtless post. You made a test script in a minute to prove it does not exist but you still want shit in the help file. You are sick.

Go whine to someone who care for your pathetic altitude. The only thing you do NOT get is that you mentioned C and Java, well, are they event driven languages you fool? Don't bother answering as you are already the fool.

I hope I showed it a little better for you this time.

Edit:

Typo

Edited by MHz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.