nikooo1608 Posted March 27, 2020 Share Posted March 27, 2020 Hey guys, I have a question, which I couldn't find anywhere in the forum. So here it is: How can I create a new variable which have a Function Return in the variable name. It sounds worse than it is. If the expression in the function is true, the function should return a value, which can then be used as a new variable with new content. Important for my project: If the expression in the function is not true, i.e. there is no return value, no variable may be created. Am I missing something? Are there easier ways? I didn't copy the whole code, because it's an bigger project. I want to end up with a couple of variables that have the return of this function in their name. Here's my code. Assign(), Eval() aren't working for me. For $a = 0 To 10 Assign(test($a), "Test Variable") Next Func test(ByRef $value) If $value = EXPRESSION "not important" Then Return $value EndIf EndFunc Link to comment Share on other sites More sharing options...
water Posted March 27, 2020 Share Posted March 27, 2020 Can you please explain what you try to achieve? The code you posted so far can become quite complex and hard to debug. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
nikooo1608 Posted March 27, 2020 Author Share Posted March 27, 2020 1 minute ago, water said: Can you please explain what you try to achieve? The code you posted so far can become quite complex and hard to debug. Like I said, I basically just want to have the Return Value of a Function as a variable name. Link to comment Share on other sites More sharing options...
water Posted March 27, 2020 Share Posted March 27, 2020 I have read and understood your OP You describe the solution you want to implement. But not always is the solution you are thinking of the best or even the only possible way to achieve a goal. So please describe in simple words what your script should do My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
nikooo1608 Posted March 27, 2020 Author Share Posted March 27, 2020 3 minutes ago, water said: I have read and understood your OP You describe the solution you want to implement. But not always is the solution you are thinking of the best or even the only possible way to achieve a goal. So please describe in simple words what your script should do I have an array that is sometimes full and sometimes not so full (not constant), and I want to make several variables out of this array (depending on expressions). array: $ a_test [5] variable that i want to have after some ifs: $ one = test $ two = hi $ four = welcome Link to comment Share on other sites More sharing options...
water Posted March 27, 2020 Share Posted March 27, 2020 But why don't you directly access the array$a_test or store the data in a new array instead of dynamically creating variables? Earthshine and FrancescoDiMuro 2 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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