Yeah, that works, but it changes on every tick what is against the idea that it should be randomized only on game start.
Yes, dynamic integers are reevaluated every time you reference them.
What you want then is something like this:
integers {
s_code_1;
s_code_2;
s_code_3;
} on_startup {
: set_integer var = "s_code_1" {(random(1))}
: set_integer var = "s_code_2" {(random(1))}
: set_integer var = "s_code_3" {(random(1))}
}