Deye Posted March 3, 2019 Share Posted March 3, 2019 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 More sharing options...
FrancescoDiMuro Posted March 3, 2019 Share Posted March 3, 2019 (edited) @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 March 3, 2019 by FrancescoDiMuro Deye 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
jchd Posted March 3, 2019 Share Posted March 3, 2019 @Deye, Short answer: No. Long answer: No, type that yourself. TheDcoder 1 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 hereRegExp tutorial: enough to get startedPCRE 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 More sharing options...
user4157124 Posted March 3, 2019 Share Posted March 3, 2019 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] . AUERLO (AutoIt error logger) Link to comment Share on other sites More sharing options...
Gianni Posted March 3, 2019 Share Posted March 3, 2019 (edited) 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... #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 March 3, 2019 by Chimp Deye 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
jchd Posted March 3, 2019 Share Posted March 3, 2019 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 hereRegExp tutorial: enough to get startedPCRE 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 More sharing options...
Gianni Posted March 3, 2019 Share Posted March 3, 2019 ....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) Deye 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Deye Posted March 3, 2019 Author Share Posted March 3, 2019 (edited) 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 March 3, 2019 by Deye Link to comment Share on other sites More sharing options...
jchd Posted March 3, 2019 Share Posted March 3, 2019 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 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 hereRegExp tutorial: enough to get startedPCRE 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 More sharing options...
Gianni Posted March 3, 2019 Share Posted March 3, 2019 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 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 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Deye Posted March 3, 2019 Author Share Posted March 3, 2019 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 More sharing options...
jchd Posted March 3, 2019 Share Posted March 3, 2019 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. Deye 1 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 hereRegExp tutorial: enough to get startedPCRE 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 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