|
Pages: [1]
|
 |
|
Author
|
Topic: very newbie question (Read 552 times)
|
|
runlogger
|
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
|
Hi runlogger  "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
|
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
|
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
|
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
|
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
|
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
|
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
|
|
|
|
|
|
|
|
Pages: [1]
|
|
|
 |
News: 01-09-08 Alpha version of REBOL 3 has been released!
2169 Posts in 562 Topics by 1224 Members
Latest Member: thyptoste
|