Jump to content

Enum Assign like


Recommended Posts

Hi,

Is there any known\UnKnown approach to enum Enum like assign even if restricted to local scope so long as it will work

AssignEnum("Opt_", 10)

; aka:
Local Enum $Opt_1 = 10, $Opt_2, $Opt_3, $Opt_4, $Opt_5, $Opt_6, $Opt_7, $Opt_8, $Opt_9, $Opt_10

Thanks

Deye

Link to comment
Share on other sites

@Deye

Enum increments the first variable from 0 (if not specified), to N.

You can specify a Step, so the increment will be like the Step specified.

In your case, you have the first variable set to 10, so the last variable is set to 19, since the Step is 1.

With Assign , you assign data to a variable, which, in this case, is already set (by Enum).

So, what AssignEnum() should do? :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

@Deye,

Short answer: No.
Long answer: No, type that yourself.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Without a descriptive name Enum seems pointless. Example:

SomeFunc($Opt_10)
SomeFunc(10)

Maybe you want something like this:

Global Enum $OPT_NAME, $OPT_DESCR, $OPT__ENUM
Global $g_aOption[10][$OPT__ENUM]

$g_aOption[0][$OPT_NAME] = ''
$g_aOption[0][$OPT_DESCR] = ''
$g_aOption[1]...

So it can be referenced like $g_aOption[10][$OPT_NAME] .

Link to comment
Share on other sites

here a possible way...
P.S.
please don't amend me that this, more than a technical solution, is a Rube Goldberg's tribute, because I already know it... :P

#AutoIt3Wrapper_Run_Au3Check=n

_example()

; this will give error since those variables where in local scope only
; ConsoleWrite($Opt_1 & @TAB & $Opt_2 & @TAB & $Opt_3 & @TAB & $Opt_4 & " ....." & @CRLF)

Func _example()
    ; -- generate variables in local scope --------
    Local $aMyVars = _AssignEnum("Opt_", 10, 10)
    For $i = 0 To UBound($aMyVars) - 1
        Assign($aMyVars[$i][0], $aMyVars[$i][1], 1)
    Next
    ; ---------------------------------------------

    ; use yours generated Opt_* vars here, in LOCAL scope for this function only
    ConsoleWrite($Opt_1 & @TAB & $Opt_2 & @TAB & $Opt_3 & @TAB & $Opt_4 & " ....." & @CRLF)
EndFunc   ;==>_example


Func _AssignEnum($VarPrefix, $iNumOfVars, $iStartValue = 0, $sStepIncrement = 1)

    If $iStartValue = 0 And StringInStr($sStepIncrement, '*') Then $iStartValue = 1
    If IsNumber($sStepIncrement) And $sStepIncrement > 0 Then $sStepIncrement = '+' & $sStepIncrement

    Local $iNextValue = $iStartValue
    Local $aVars[$iNumOfVars][2]

    For $i = 1 To $iNumOfVars
        ; Assign($VarPrefix & $i, $iNextValue)
        $aVars[$i - 1][0] = $VarPrefix & $i
        $aVars[$i - 1][1] = $iNextValue
        $iNextValue = Execute($iNextValue & $sStepIncrement)
    Next
    Return $aVars
EndFunc   ;==>_AssignEnum

 

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Haha, you can even add a bit of complexity by mimicking the other possibilities of plain Enum Step parameter (-5, *4), one more gearing to this machinery.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

:lol: ....you do not need to complicate it any further because it is ready for those parameters (see the fourth and the fifth parameter of the _AssignEnum function) B)

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

To all, Sorry for the delay @ responding .. Had to jump out 

@Chimp, 

This indeed looks like a magic voodoo spell to me, don't feel like I need to fully understand for now ;)
Going to use this as if it was a built in function .. 🙌
 
Worked flawlessly for me.

Thanks 
Deye 

Edited by Deye
Link to comment
Share on other sites

16 minutes ago, Chimp said:

(see the fourth and the fifth parameter of the _AssignEnum function)

I read "third and fourth", but this doesn't cover Step *3 :evil:

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

23 minutes ago, Deye said:

To all, Sorry for the delay @ responding .. Had to jump out 

@Chimp, 

This indeed looks like a magic voodoo spell to me, don't feel like I need to fully understand for now ;)
Going to use this as if it was a built in function .. 🙌
 
Worked flawlessly for me.

Thanks 
Deye 

You are welcome,

even if I posted it just for fun, I'm glad it's useful for you too..:)

 

8 minutes ago, jchd said:

I read "third and fourth", but this doesn't cover Step *3 :evil:

sorry, I forgot to say that the fourth parameter should be passed as a string if it is different from a positive i.e. '* 3' or '-5' in this mode should work regularly :evil:

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Anyways,

I get it now, what FrancescoDiMuro pointed out as well  
I could have made my own function if I understood better what Enum was doing 🏳️

Basically a simple var enumeration when returns some how need to have 2\3 or more digits long, Popular when Dealing with menus ..

Thanks again 

Deye

Link to comment
Share on other sites

57 minutes ago, Chimp said:

I forgot to say that the fourth parameter should be passed as a string if it is different from a positive i.e. '* 3' or '-5'

OK, granted. Sorry for noise.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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...