Jump to content

Function Return in Variable Name


Recommended Posts

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

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 2022-02-19 - Version 1.6.1.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 (NEW 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

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

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 2022-02-19 - Version 1.6.1.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 (NEW 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

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

But why don't you directly access the array$a_test or store the data in a new array instead of dynamically creating variables?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...