acantor Posted January 4, 2019 Report Share Posted January 4, 2019 I would be curious to learn how other Macro Express users would handle this situation. The task is to copy data from several fields, and insert the data into corresponding fields in another application, but in a different order. 12 pieces of information need to be copied. Here are the two approaches. 1. Collect the data in an array %Value[1]% %Value[2]% %Value[3]% ... %Value[12]% After collecting the data, the macro switches to the second application, and inserts the text into fields, but in a different order: %Value[2]% %Value[3]% %Value[6]% etc. 2. Use descriptive variable names %Honorific% %FirstName% %SurName% %Address1% %Address2% etc. It seems to me that collecting data in an array is probably the more elegant and efficient way to get the job done. On the other hand, using descriptive variable names make it clearer what the macro is doing, and make it easier to match up corresponding fields in the two applications. Which approach would you use? Quote Link to comment Share on other sites More sharing options...
Cory Posted January 4, 2019 Report Share Posted January 4, 2019 I'm a fan of arrays but in this case I would want my variables to represent the type of thing it will hold. It helps make your code more readable which can grant huge dividends later. I knwo when I revisit code a year later it takes me time to reacquaint myself. But if these came in and an array were generated as the result of a split, I'd tend to leave the array of strings as is for performance. IE it seems silly to copy all these array variables to new named variables. BTW I often have multiple arrays that virtually form a Db table by using the index number as a quasi-row-number. So in your example above I'd have like in your second example but they would be arrays and each index would represent another individual's variables. My final word is that in most cases performance is not an issue. In those cases, do whatever you can to make it simpler and easier to understand after you have been away form it for a time. I try to write my macros as if I was handing it off to someone else to maintain. Many times I've been very happy I did. Quote Link to comment Share on other sites More sharing options...
rberq Posted January 4, 2019 Report Share Posted January 4, 2019 1 hour ago, Cory said: in most cases performance is not an issue. In those cases, do whatever you can to make it simpler and easier to understand after you have been away form it for a time. I try to write my macros as if I was handing it off to someone else to maintain. Many times I've been very happy I did. I agree 100% -- said he who still mostly uses ME3🙂. Quote Link to comment Share on other sites More sharing options...
acantor Posted January 8, 2019 Author Report Share Posted January 8, 2019 Thanks for your input. I agree. However, if there were many more data points to collect -- say 100 instead of 12 -- I might be tempted to use arrays, but to write a bunch of comments to guide future maintenance, e.g., // Text Variable %Value[1 to 100]% // [1] = Honorific // [2] = First name // [3] = Last name ... // [100] = Date of last update Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.