r/code • • May 21 '24

Help Please Automatic generation of repetitive code (Not AI)

I feel like I'm missing something simple.

There has got to be a quick and easy way to generate repetitive code that only has a few changes - such as inserting values from a list. (Very similar to how a mail merge worked back in the day.)

When I try and search for this functionality, I get results for AI code generation. That's cool and all, and they actually work for this, but seems like massive overkill for a simple problem.

If I search for mail merge functionality, I'm getting scripts and specific results for using email, which isn't what I want either.

Essentially, I want a template block of code that has placeholders that will be replaced with values from a list(s) I provide.

I'm guessing there's a specific term for this that I'm just unaware of. It feels like the sort of thing you'd be able to find a simple online tool for.

3 Upvotes

7 comments sorted by

View all comments

Show parent comment

2

u/Tychonoir May 22 '24

Just make a PDF or Google Doc with input boxes

This doesn't sound right, though. If I've got to input the data manually, that's exactly what I'm trying to avoid.

Looks like I can kind of use Google Sheets ARRAYFORMULA( SUBSTITUTE() ) to sort of get there.

Honestly, I could have written a bit of code to do this by now - but it felt like I was just reinventing the wheel.