AutoIt & Arrays & Scripts, Oh My!

They say life comes at you fast. Well so do programming languages. Ok, so that sounded cooler in my head. You see, within 3ds Max, what is available is more accurately called scripting and not programming. It is very powerful… within Max. It was also created for artists, and people that don't know anything about writing code. There is a “Listener” in Max that if you do an action, it returns the script equivalent of that action. So you can copy that, change up a few parameters, and suddenly you have a working script. You can get way more complicated if you so desire, but much of it is “easy” to pick up.

AutoIt, on the other hand, is still scripting (I believe), but much more complicated. At least to someone like myself. So I’ve spent much of this week reading through Matt and William’s scripts. Things like:

local $read_file = FileRead($folder&"⧵"&$file_array[$this_file])
local $header = "Unknown"
$specs = _StringBetween($read_file,"-----System Specs-----","----------")
If not @error Then
	local $spec_array = StringSplit($specs[0],@CRLF)
	For $this_spec = 1 to $spec_array[0]
		If StringInStr($spec_array[$this_spec],$column_name) Then
			$header = Stringreplace($spec_array[$this_spec],$column_name&": ","")
			If StringInStr($header,",") Then
				local $temp_split = Stringsplit($header,",")
				$header = $temp_split[1]

Yeah… Lots of that, while sitting at home alone. At one point I swear I started to hear Sarah McLachlan singing “In the arms of angels” when I started to open another script. Ok, that was probably my wife listening to Spotify while cleaning out the spare bedroom, but the point is, there was a lot of very dry reading this week.

The week wasn't just dry reading. I was able to type some very dry scripts as well. My goals in AutoIt are to be able to install Max onto a local machine from a network drive, copy all the needed test files, run the benchmark, upload results to a network location, then uninstall Max and remove the test files. Last week I did the easy part of launching Max and running the benchmark. This week I managed to figure out how to install Max from a network location, sort of. For the moment I’m installing to my C: drive from my E: drive, but in theory I just need to change a dozen or so links in four or so files and it should be the same… right? What could go wrong?

I also managed to get the test files to copy from one location to another. The only trickiness with this was some files needed to go to different locations. One file needs to go to Max’s “startup” folder so the benchmark will launch when Max opens, the rest need to go to a different folder. For this I didn’t want to use the generic project folder, because I want to be able to delete the whole thing after. If our Repair department was to use this benchmark, I wouldn’t want it erasing the customer’s files. Alternatively I could erase each file one at a time, but that just seems inefficient.

Where I’ve left off has been more complicated. Within Max, the benchmark is able to write the results to a txt document. That is fine for one computer, but I need to compile a dozen results into one spreadsheet. This is getting into arrays, and lots of variables, and the like. I’m very glad I have Matt’s scripts to steal, I mean reference. Even at that, there needs to be a decent amount of translation. Since this won't be the only time I need to make a script like this, I really want to make sure I understand how it is working.

Honestly, this process has been slower and more difficult than I expected. When I first joined the team, I was excited how relatively easy the scripting was going. Turns out Max really holds your hand. But now the training wheels are off, and I’m really hoping I don’t have to learn something like C++ or JavaScript.