# Putting a variable into a KirbyBase database cell

**URL:** <https://www.ruby-forum.com/t/putting-a-variable-into-a-kirbybase-database-cell/70393>\
**Category:** Ruby\
**Created:** [September 28, 2006, 8:47pm UTC](https://www.ruby-forum.com/t/putting-a-variable-into-a-kirbybase-database-cell/70393 "2006-09-28T20:47:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [September 28, 2006, 8:47pm UTC](https://www.ruby-forum.com/t/putting-a-variable-into-a-kirbybase-database-cell/70393/1 "2006-09-28T20:47:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [September 28, 2006, 8:53pm UTC](https://www.ruby-forum.com/t/putting-a-variable-into-a-kirbybase-database-cell/70393/2 "2006-09-28T20:53:22Z")

</div>

On Sep 28, 2006, at 2:47 PM, Peter B. wrote:

> 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 W.

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [September 29, 2006, 5:47pm UTC](https://www.ruby-forum.com/t/putting-a-variable-into-a-kirbybase-database-cell/70393/3 "2006-09-29T17:47:49Z")

</div>

unknown wrote:

> On Sep 28, 2006, at 2:47 PM, Peter B. wrote:
> 
> > 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 W.

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
