J
jesse.r.brown
I have run across something that I can quite figure out at the moment.
Here is the section of code I am dealing with:
# construct a string that can be
# output in the structure definition
# [depth] is the current tab depth
# [tab] is the tab width
def struct_str(depth,tab)
indent = " " * tab * depth
str = indent + "\"#@name\", \"#@fmt\", #@args,\n"
str += indent + "%15s %10s - #@err_msg \n" % [@name, @fmt]
I get an error when trying to assign @fmt to the %10s.
I _think_ the problem is that I have, in the @fmt variable, a c-style
printf format string. The error I get is:
../commands.rb:39:in `%': too few arguments (ArgumentError)
Am I doing something incorrectly? Or is there an easy way around this?
Note:
The @fmt come from a user-provided file, so careless translations will
lead to undefined effects. I want to try and fix this localy if
possible.
Thanks in advance for any help.
Here is the section of code I am dealing with:
# construct a string that can be
# output in the structure definition
# [depth] is the current tab depth
# [tab] is the tab width
def struct_str(depth,tab)
indent = " " * tab * depth
str = indent + "\"#@name\", \"#@fmt\", #@args,\n"
str += indent + "%15s %10s - #@err_msg \n" % [@name, @fmt]
I get an error when trying to assign @fmt to the %10s.
I _think_ the problem is that I have, in the @fmt variable, a c-style
printf format string. The error I get is:
../commands.rb:39:in `%': too few arguments (ArgumentError)
Am I doing something incorrectly? Or is there an easy way around this?
Note:
The @fmt come from a user-provided file, so careless translations will
lead to undefined effects. I want to try and fix this localy if
possible.
Thanks in advance for any help.