In general, it’s best to avoid global scope, and you could instead write a function that returns the error-producing i
:
function errorchar(limit)
for i in 1:limit
try
Char(i)
catch
return i
end
end
end