|
|
|||||||
Can someone give me a hand with this function to tell me where I am going wrong. It is erroring on the redim of the array. At first I thought it was because I was not specifying the second dimension in the original dim, but I fixed that and it is still not working. I cant think of another problem that may be hitting this. Code:
Many thanks |
||||||||
|
|
|||||||
IIRC, multi-dim arrays cannot be redimmed. |
||||||||
|
|
|||||||
ARRRGGGHHHHH, I did not want to hear that. That is going to make this even more fun. (We need a crying emotiocon ) That means I have to size up what I need before I originally dim the array. Thanks for the information |
||||||||
|
|
|||||||
You may redim multi-vectored arrays, but you may only redim the right-hand index when you are using the PRESERVE keyword. In other words, "ReDim Preserve $ValArray[$VANdx, 1]" will not work, but "ReDim Preserve $ValArray[1,$VANdx]" is fine. |
||||||||
|
|
|||||||
I finally got this working. Once my mind got going I thought about declaring the var when I had enough info to do it. That way I don't have to redim. My problem now is testing the multi dim array outside of its function. Here is my full code . Can I get a pointer on this? If I treat the result as a 1 dim array (? $Vals[$Ndx1]) it goes fine, but as soon as I let it show it is a multidim, I ge the error that kix expects ']'. As I provided this I am perplexed. Code:
|
||||||||
|
|
|||||||
Read my post or look up the manual page for ReDim where the action of the PRESERVE keyword on multi-dimension arrays is explained. |
||||||||
|
|
|||||||
Are you sure that you are returning the correct array here: Code: $ArrayEnumValues = $Names Shouldn't that be: Code: $ArrayEnumValues = $ValArray |
||||||||
|
|
|||||||
OOOPS... Thanks(that makes 2 times today I have missed a proper return array var). Almost time to kick myself I read your reply about the rediming. I will probably try a test on that soon, but since I already had the info needed to dim properly, it will take less processor cycles this way, so I will use what I had at this point for the 'formal' diming. That and I found another error too. I missed a character in a var name. Here is the final function for those of you interested. I will try to work up a header and submit this more formally in the coming week. Code:
|
||||||||
|
|
|||||||
Use SetOption("Explicit","ON") - it will save you a lot of aggravation. BTW, you are implicitly declaring $VANdx by assigning a value to it, then you are explicitly declaring it in a DIM statement a couple of lines later on. Code: $VANdx = 0 |
||||||||
|
|
|||||||
Completed. Here is the adjusted code: Code:
Many thanks for the pointers |
||||||||
|
|
|||||||
Please make sure you're adhering to our UDF requirements as the SETOPTION=ON is a pre-requisite for posting this UDF. Also, as you've decided to post this UDF, I will repeat what I already told you in our PM conversations, nonwithstanding your dislike of the KiXtart function names. This UDF can cause confusion with the already existing UDF ArrayEnumValue() and thus (in accordance with the KiXtart nomenclatura) should rather be called ArrayEnumValuesData() or ArrayEnumValuesNames() or similar. The nomenclatura, as set forth by Microsoft, is documented in http://support.microsoft.com/default.aspx?scid=kb;EN-US;256986 . Registry hives contain registry keys (subkeys). Keys contain one or more values, htere is alwasy a default value. A value contains data. |
||||||||
|
|
|||||||
I found some more error locations and had to update this code. However in this update I have run into further problems. For some reason(of which I don't understand) I am losing the value in my array. The Current incarnation of this function is as follows: Code:
Anyone have any ideas on this? |
||||||||
|
|
|||||||
Anyone have any ideas here? |