Well, 99% of times when I see people using dynamic code, they should be using arrays. Dynamic code and dynamic variables have definite uses, but they are an incredibly complex answer to a simple question most of the time.
Using dynamic variables:
for "_i" from 0 to 5 do
{
call compile format ["frog%1 = %2", _i, _i * 10];
};
hint str call compile ["frog%1", 3]; // => 30
(you have 6 variables called frog0 to frog5).
Using arrays:
frog = [];
for "_i" from 0 to 5 do
{
frog set [_i, _i * 10];
};
// frog => [0, 10, 20, 30, 40, 50]
hint str (frog select 3); // => 30
or
frog = [];
for "_i" from 0 to 5 do
{
frog = frog + [_i * 10];
};
// frog => [0, 10, 20, 30, 40, 50]
hint str (frog select 3); // => 30
If nothing else, when you compile a string in your script, rather than using compile preprocessFileLineNumbers on a file, you won't get proper error messages if there is an error. Thus, you should avoid it at all costs anyway!
Incidentally, if you aren't referring to something outside of a script, it is always better to use local variables (_frog) rather than globals (frog). All you need to do is declare all of the locals in a private statement at the start of the script, to avoid scope issues, which I assume is why people avoid locals.