Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: very newbie question
Pages: [1] Print
Author Topic: very newbie question  (Read 707 times)
runlogger
Newbie
*
Offline Offline

Posts: 5


View Profile
very newbie question
« on: December 23, 2007, 12:06:15 AM »

Hi, I am 16 and new to Rebol. How do I insert a value derived from a field as a variable into db.r (which I downloaded from Dogeash Software)? I realize this a a very simple question, but your help would be greatly appreciated.

thanks very much,
Scott
Logged
notchent
Newbie
*
Offline Offline

Posts: 40


View Profile WWW
Re: very newbie question
« Reply #1 on: December 23, 2007, 10:50:50 AM »

Hi runlogger Smiley

"value" refers to the value entered into the GUI field.  Convert it to a block using "to-block", then use the "db-insert" function in db.r to insert that value in the table you've created.  Try this:

rebol []

do %db.r
db-create a-table-name [item]

view layout [
   text "Enter text item, and press <ENTER>:"
   field [
      db-insert a-table-name (to-block value)
      d/data: db-select * a-table-name
      show d
   ]
   text "Current contents of database:"
   d: text-list
]
Logged

runlogger
Newbie
*
Offline Offline

Posts: 5


View Profile
Re: very newbie question
« Reply #2 on: December 23, 2007, 04:28:14 PM »

Hi Notchent,

Thanks for the advice...it has helped. The trouble I am having now is how to combine values from multiple fields [field1 field2, etc] into the block value. I tried putting in them into a single variable like this:

value: [field1 field2]

I've also tried putting the [db-insert table-name (to-block value)] statement beneath each field, but obviously I am still off-track. Again, your help is much appreciated!

Scott
Logged
notchent
Newbie
*
Offline Offline

Posts: 40


View Profile WWW
Re: very newbie question
« Reply #3 on: December 23, 2007, 11:10:06 PM »

Here are several ways you can combine values into a block:

someblockname1:  copy []   ; assures that the block is created empty
append someblockname1 field1/text
append someblockname1 field2/text

someblockname2:  reduce [field1/text field2/text]

someblockname3:  compose [(field1/text) (field2/text)]

Logged

runlogger
Newbie
*
Offline Offline

Posts: 5


View Profile
Re: very newbie question
« Reply #4 on: December 27, 2007, 09:03:35 PM »

Thanks, Notchent. That works great! I have one more db.r question for you...I can't get the db-select function to work. I have tried:

get/data: db-select field-name table name
show get-data
get: view-list

Is this close? The Dobeash documentation isn't real clear (at least to me) on this. I want to populate a page with selected fields from my database. Any help you can provide would be awesome.

Thanks again,
Scott
Logged
henrikmk
Newbie
*
Offline Offline

Posts: 49


View Profile
Re: very newbie question
« Reply #5 on: December 28, 2007, 10:58:02 AM »

I don't know about the code you are writing, but you are overwriting the GET function, which is an important standard function in REBOL. If your code is crashing, it may very well be because of that.
Logged
runlogger
Newbie
*
Offline Offline

Posts: 5


View Profile
Re: very newbie question
« Reply #6 on: December 28, 2007, 05:35:24 PM »

Hi Henrikmk,

You may well be right about my use of 'get'. What would really help at this point is some example code. I have produced a table and input some data with 'db-insert'; now I am trying to extract the data to a window with 'db-select'.

I have found that 'print db-select * my-table' will produce my data on the view console, so I know it is accessible, but I haven't be able to produce it on a window layout. So my question is: What do I need to do to the 'db-select * my-table' statement to make my data appear on a screen?

Any help (and especially an example of the appropriate code) would be greatly appreciated!

Thanks again,
Scott
Logged
runlogger
Newbie
*
Offline Offline

Posts: 5


View Profile
Re: very newbie question
« Reply #7 on: December 29, 2007, 01:45:08 AM »

For others who may be following this thread in search of answers to the same problem, here is a (very simple) solution I pieced together from other posts on this site:

db-view: does [db-select/sum field-name table-name]
view layout [text-list data db-view]

Thanks again, Notchent, for your help.

Scott
Logged
btiffin
Jr. Member
**
Offline Offline

Posts: 58


View Profile
Re: very newbie question
« Reply #8 on: January 06, 2008, 10:02:59 PM »

Also, take a peek at http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=rebdbgui.r

It's a script (that attempts) to show some ways to use RebDB with RebGUI.

Cheers,
Brian
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: very newbie question
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 29, 2008, 02:32:32 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2234 Posts in 582 Topics by 1745 Members
Latest Member: vectlycle

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc