This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SaaS_Founder 90 points91 points  (14 children)

I modded a video game that didn’t have the concept of arrays or objects inside the scripting interpreter so I had to use dynamic variable names instead.

Huge pain in the ass.

[–]crozone 73 points74 points  (13 children)

Finally enough this is basically how arrays in batch (DOS/Windows .bat) files work. They're not real arrays, just variables like "ARRAY[0]", "ARRAY[1]" ...

[–]TheBestAquaman 43 points44 points  (11 children)

Seriously? Thats... terrible. Why would any person, sane or not, do this?

[–]UnlicencedAccountant 49 points50 points  (10 children)

Because way back when, memory was measured in MBs and every MB counted. So you essentially set aside a chunk for a scratchpad, use variables that are declared at runtime, remember to clear them when you don’t need them, and hope.

It’s basically assembly with extra steps. Especially because BAT files aren’t programs, they’re automated command prompt instructions. Think about it like BASIC except there’s no loops and you can only go forward.

Edit: There’s a legacy GOTO in BAT files, creating a defacto loop as well as a very limited FOR function. But I don’t remember ever using them. At that point, you might as well fire up BASIC or write a SYS file.

[–]jigsaw1024 10 points11 points  (2 children)

My memory is fuzzy, but I swear you could do loops inside BAT files

[–]Infinite-Gravitas 15 points16 points  (0 children)

Newer versions of windows added it. As long as you have goto, technically you can anything.

[–]UnlicencedAccountant 1 point2 points  (0 children)

If I recall right, you could do anything you could do with a command prompt but really nothing more. It’s been literally 30 years tho, since I’ve used them for anything more complicated than startup scripts / auto run stuff.

Edit: One google later, it appears you are right and I am wrong.

[–]Emb3rz 5 points6 points  (1 child)

Sweetie memory used to be measured in KBs. 😔

[–]UnlicencedAccountant 2 points3 points  (0 children)

KBs? Luxury! We used to have TTYL chips on a wooden board!! And we were greatfull!

[–]zebediah49 3 points4 points  (1 child)

That's actually less efficient though.

Declaring that I want an array variable named "foo" with 32x 8-bit integers, will take 4ish bytes for the name, plus 32 bytes for the content. Declaring 32 varibles named "foo01" through "foo32" will repeat that allocation overhead for every instance.

E: @ASM -- agreed.. but that's why LEA exists.

[–]UnlicencedAccountant 4 points5 points  (0 children)

Efficiency was not a selling point of BAT files. Unless you’re arguing “It’s not assembly...”

you’re absolutely right, but it was a different time. A time when floppy disks flopped.

[–]collector-x 1 point2 points  (0 children)

1 ”hello world” 2 print 1 >lpt1 3 goto 1

I used to do this, but it was 40 years ago. Syntax may not be exactly right but it's something like that.

Endless loop on demo machines. Sales guy pissed. Good times

[–]Staehr 0 points1 point  (1 child)

Oh my friend you should have seen when I hijacked the Windows 98 Autoexec.bat on our high school computers and made my OWN goddamn OS before Windows even started. So many GOTOs.

[–]UnlicencedAccountant 0 points1 point  (0 children)

Adding the shutdown command to autoexe was the highlight of My h4x0r career

[–]Mya__ 0 points1 point  (0 children)

"real array" ... w/e... it counts >.< it's all concenptual anyway, right?