darkshadow791 Posted April 20, 2007 Share Posted April 20, 2007 I have the following code that is part of a notepad-like program: expandcollapse popupFunc 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. Note Taker Lite - a note taking / converting tool. Link to comment Share on other sites More sharing options...
Valuater Posted April 20, 2007 Share Posted April 20, 2007 (edited) This will do it ( just copy the print function idea ) $M_File = GUICtrlCreateMenu("File") $File_Save = GUICtrlCreateMenuitem("Save", $M_File) GUICtrlSetOnEvent(-1, "Saver") Func Saver() Save(1) EndFunc 8) Edited April 20, 2007 by Valuater Link to comment Share on other sites More sharing options...
darkshadow791 Posted April 20, 2007 Author Share Posted April 20, 2007 (edited) Thanks this works, but the reason I posted here was actually to find out why it won't work this way, not so much how to fix it. Thanks for your help, though! Edited April 20, 2007 by darkshadow791 Note Taker Lite - a note taking / converting tool. Link to comment Share on other sites More sharing options...
MrCreatoR Posted April 20, 2007 Share Posted April 20, 2007 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 Russian Community My Work... Spoiler Projects: 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 ProgramUDFs: 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 Examples: 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 ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
Developers Jos Posted April 20, 2007 Developers Share Posted April 20, 2007 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 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
darkshadow791 Posted April 22, 2007 Author Share Posted April 22, 2007 So function parameters just don't work with events or hotkeys? :/ Note Taker Lite - a note taking / converting tool. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 22, 2007 Developers Share Posted April 22, 2007 So function parameters just don't work with events or hotkeys? :/Correct ... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
MrCreatoR Posted April 22, 2007 Share Posted April 22, 2007 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 Russian Community My Work... Spoiler Projects: 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 ProgramUDFs: 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 Examples: 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 ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
Developers Jos Posted April 22, 2007 Developers Share Posted April 22, 2007 (edited) 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 April 22, 2007 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
darkshadow791 Posted April 23, 2007 Author Share Posted April 23, 2007 I looked through onevent and gui*onevent and it says nothing about parameters being ignored though. Note Taker Lite - a note taking / converting tool. Link to comment Share on other sites More sharing options...
MHz Posted April 23, 2007 Share Posted April 23, 2007 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. Link to comment Share on other sites More sharing options...
darkshadow791 Posted April 23, 2007 Author Share Posted April 23, 2007 (edited) 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 April 23, 2007 by darkshadow791 Note Taker Lite - a note taking / converting tool. Link to comment Share on other sites More sharing options...
MHz Posted April 24, 2007 Share Posted April 24, 2007 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) EndFuncThe 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. Keep ya $0.02 Link to comment Share on other sites More sharing options...
darkshadow791 Posted April 24, 2007 Author Share Posted April 24, 2007 (edited) 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 April 24, 2007 by darkshadow791 Note Taker Lite - a note taking / converting tool. Link to comment Share on other sites More sharing options...
MHz Posted April 24, 2007 Share Posted April 24, 2007 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. Link to comment Share on other sites More sharing options...
darkshadow791 Posted April 24, 2007 Author Share Posted April 24, 2007 *sigh* You really don't understand this do you? Fine. Specifically what in the help file are you saying does not exist? Note Taker Lite - a note taking / converting tool. Link to comment Share on other sites More sharing options...
evilertoaster Posted April 24, 2007 Share Posted April 24, 2007 (edited) 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 ithttp://www.autoitscript.com/forum/index.php?showtopic=9847Alot 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 April 24, 2007 by evilertoaster Link to comment Share on other sites More sharing options...
MHz Posted April 25, 2007 Share Posted April 25, 2007 (edited) *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 April 25, 2007 by MHz Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now