(See the best response by Kaiochao.)
icon = 'inventBox.dmi'
layer = 2
free = "TRUE"
icon_state = "r1c1"
screen_loc ="Imap:1:13,6:21"
//box 2 blabla
//box 3 blabla etc


for(num=1,num<=24, num++) //loops through each invent box
if(box[num].free = "TRUE")

Problem description:

"if(box[num].free = "TRUE")" gives me an error of: 122:error: .: missing comma ',' or right-paren ')'

I am trying to loop through each inventBox obj to check if they are "free". if they are, then I replace box[num] obj with a different obj, by setting box[num].screen_loc = null (so it doesn't show up on the map) and put the new obj in its screen_loc

but the if statement is giving me a syntax error it seems.. so I'm not sure how to get around that yet

I have even tried this: and still get the error
if(var/obj/InventBox/box[num].free = "TRUE")

That's not how you search for objects. You'd be able to find it if you did this:

That loops through every object of that type that exists. Narrow down your search from there. You can also create a list before you search if you know exactly where you need to search, and search through that list rather than every instance.
Best response
You can't use the [] operators like that outside of string literals. It actually means something entirely different.

It also doesn't make sense that you're trying to modify a variable of a type path. You need actual instances of that type to use, using "new".

It looks like you might be able to use basic math to create your boxes at their proper positions instead of having a bunch of different types of them.

You need to be taking advantage of a list to store your objects so you can actually access them.

Your if() at the end is using = (assignment) instead of == (comparison), which is also bad.
Alright I think I understand it better now. thanks!

I managed to do what I wanted to do