goldenix Posted June 7, 2008 Share Posted June 7, 2008 (edited) I did not find any Tutorials on this, so im little lost hire, if you know any feel free to recommend.Basically this is what im trying to do:Sample: ( As you see i have no idea what im doing based on some the UDFS i found around hire. )$Size = 'Big' $appleatributes = _apple_atributes(10,$Size,'Red ','') MsgBox(0,'Apple attributes: Amount : Size : Color : Weight',$appleatributes) Func _apple_atributes($amount,$Size,$Color,$Weight) if $Size = 'Big' Then $Weight = ' 1 KG' $appleatributes = $amount & $Size & $Color & $Weight EndFuncEDIT: See Post 6 & 8 For solution Edited June 8, 2008 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
Valuater Posted June 8, 2008 Share Posted June 8, 2008 $Size = 'Big' $appleatributes = _apple_atributes(10, $Size, 'Red ', '') MsgBox(0, 'Apple attributes: Amount : Size : Color : Weight', $appleatributes) Func _apple_atributes($amount, $Size, $Color, $Weight) If $Size = 'Big' Then $Weight = ' 1 KG' $appleatributes = $amount &" "& $Size &" "& $Color &" "& $Weight Return $appleatributes EndFunc ;==>_apple_atributes 8) Link to comment Share on other sites More sharing options...
goldenix Posted June 8, 2008 Author Share Posted June 8, 2008 (edited) Wait How do you know What to return?I mean if user calles : $Getinfo = _apple_atributes(10, $The_color,'1 Kg') How do you assign a value to it, in the return function Return $appleatributes ? We assume that Func _apple_atributes is loacated in the different file & you use Include, to include ur UDF file. See we dont know what variable user will choose, How can this be solved, see the code:$The_color = 'Red' $Getinfo = _apple_atributes(10, $The_color,'1 Kg') MsgBox(0,'Amount : Color : Weight',$Getinfo ) Func _apple_atributes($AMOUNT,$COLOR,$WEIGHT) ; 10, Red, 1 Kg return _apple_atributes($AMOUNT,$COLOR,$WEIGHT) ; 10, Red, 1 Kg EndFunc Edited June 8, 2008 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
Valuater Posted June 8, 2008 Share Posted June 8, 2008 If the function is an "Include" do this... $The_color = 'Red' $Getinfo = _apple_atributes(10, $The_color,'1 Kg') MsgBox(0,'Amount : Color : Weight',$Getinfo ) thats all 8) Link to comment Share on other sites More sharing options...
goldenix Posted June 8, 2008 Author Share Posted June 8, 2008 Maybe I should explain more clearly, Im making an UDF to get specific item from GUI listview, to make it easy to use, & it works, if the code looks like Code 1:The problem is _Listview_UDF_Get_Item(1,1) If user Calls: MsgBox(0,'',_Listview_UDF_Get_Item(1,1)) Result must be Item1.1 But for this to happend the _Listview_UDF_Get_Item(1,1) must Equal $getitem from Code 2 function. So the Question, how can i make this happen?Code 1$getitem = _Listview_UDF_Get_Item(1,1); Row Nr, Column Nr MsgBox(0,'Row 1 / Col 1',$getitem ) ;~ ================================================================== ;~ #include <MY_UDF.au3> Func _Listview_UDF_Get_Item($Da_Row,$Da_Column); Row 1, Column 2 $getitem = 'Item1.1';get item text from Row 1 Column 1 Return $getitem EndFunc ;~ ==================================================================oÝ÷ Ø*{f®¶sd×6t&÷Âb33²b33²ÅôÆ7GfWuõTDeôvWEôFVÒã·âÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓУ·â6æ6ÇVFRfÇC´ÕõTDbæS2fwC°¤gVæ2ôÆ7GfWuõTDeôvWEôFVÒb33c´Fõ&÷rÂb33c´Fô6öÇVÖâ²&÷rÂ6öÇVÖâ b33c¶vWFFVÒÒb33´FVÓãb33³¶vWBFVÒFWBg&öÒ&÷r6öÇVÖâ ¤VæDgVæ0£·âÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÐ My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
MHz Posted June 8, 2008 Share Posted June 8, 2008 Maybe I should explain more clearly,Your explanation is as clear as your understanding but nice try. I do not understand your issue fully even after reading your last post several times over. Look in the help file for Func...Return...EndFunc for UDF creation tutoring. So about your question of knowing what variable is passed to a UDF? The UDF does not care about the name of the variable when you are passing by value. This means that the UDF parameter variable gets the value from the variable that passes the value in the function call. If you pass the parameter by reference, then the name of the variable remains the same no matter which one you pass in the function call, but the value of that variable can be changed by the UDF. Here is an example that may help you understand. ; Assign global variable with value of 100 $variable = 100 ; _UDF_ByValue() only makes a copy of the value of $variable ; to use and the copied value is stored in $parameter. $return_value = _UDF_ByValue($variable) MsgBox(0, '_UDF_ByValue()', '$return_value = ' & $return_value) ; _UDF_ByReference() expects a variable as it will change the value of $variable _UDF_ByReference($variable) MsgBox(0, '_UDF_ByValue()', '$variable = ' & $variable) Exit Func _UDF_ByValue($parameter) ; The temporary variable $parameter contains the value ; of $variable and adds 100 to it and then returns that value ; back to $return_value. $parameter is then destroyed as the ; function ends. Return $parameter + 100 EndFunc Func _UDF_ByReference(ByRef $parameter) ; $parameter points to the memory location of $variable ; and adds the value of 100 to it so $variable now equals 200. ; $parameter is then destroyed as the function ends. $parameter = 200 EndFunc It is rather simple when you remove the doubt. Try making various test scripts until the doubts are answered. Link to comment Share on other sites More sharing options...
martin Posted June 8, 2008 Share Posted June 8, 2008 Maybe I should explain more clearly, Im making an UDF to get specific item from GUI listview, to make it easy to use, & it works, if the code looks like Code 1:But why did you remove the line Return $getitem in the Code2 version? If you left it there it would work.(AutoIt tags messed up again when I replied to the post. I really dislike the AutoIt tags. See my signature about dental decay.) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
goldenix Posted June 8, 2008 Author Share Posted June 8, 2008 Your explanation is as clear as your understanding but nice try. I do not understand your issue fully even after reading your last post several times over.Thank you for the samples. This is what I was looking for: My UDF Works nice now. $e = _UDF_ByReference(100,200) MsgBox(0, 'Sample 1', $e) ;~ ---------------------------------------------- MsgBox(0, 'Sample 2', _UDF_ByReference(200,200)) ;~ ---------------------------------------------- Func _UDF_ByReference($parameter1,$parameter2) $xxx = $parameter1 + $parameter2 Return $xxx EndFunc My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] 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