putting a variable into a KirbyBase database cell

P

Peter Bailey

Hi,
With a lot of help from Jamey, the KirbyBase inventor, I've managed to
get a script that does what I want it to. I've proven that I can
populate my database properly. But, so far, I've only been able to
update my table if I put in literal values, like the value "39" below.
But, in my real world, I need to put a variable in there. It's a
variable derived prior to this in the program. It's named "$totalpages."
If I put #{$totalpages} in place of the "39" below, I get a parsing
error:

:/PageCounts/pagecounter.rb:91: parse error, unexpected kEND


Dir.glob("*.ps").each do |dirfile|
result = pageinfo_tbl.select:)recno, :filename) { |r| dirfile =~
Regexp.new(r.filename) }
pageinfo_tbl.update:)pagecount=>39) { |r| r.recno ==
result.first.recno } unless result.empty?
end

Thanks,
Peter
 
G

gwtmp01

Hi,
With a lot of help from Jamey, the KirbyBase inventor, I've managed to
get a script that does what I want it to. I've proven that I can
populate my database properly. But, so far, I've only been able to
update my table if I put in literal values, like the value "39" below.
But, in my real world, I need to put a variable in there. It's a
variable derived prior to this in the program. It's named
"$totalpages."
If I put #{$totalpages} in place of the "39" below, I get a parsing
error:

You don't want #{$totalpages} but simply $totalpages.

The #{...} notation is for use within a string such as:

"There are #{$totalpages} total pages"

Gary Wright
 
P

Peter Bailey

unknown said:
You don't want #{$totalpages} but simply $totalpages.

The #{...} notation is for use within a string such as:

"There are #{$totalpages} total pages"

Gary Wright

Thanks, Gary. Yeh, I tried that too, without the braces. I didn't get
the parse error, but, I didn't get the results I needed, either. I found
that I have some variable problems. But, thanks for the explanation.
I've always been confused about when to use #{ or not.
-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top