Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save a value to a block instead of the word label that represents it

I am trying to save a few string values into a block so that I can save that block to a text file. I am getting these values from a form using VID.

One way to do this would be to simply save strings to the file. But I would prefer being able to retrieve the data as a block.

This is what I intend to do:

view layout [
    contact-name: field
    save-button: btn "Save" [
        saved-data-block: copy []
        append saved-data-block [[contact-name: contact-name/text]] ;problem here
        save my-file saved-data-block
    ]
]

For an input like Rebol User in the name field, the content stored in the file should be something like [contact-name: "Rebol User"], but the content is [contact-name: contact-name/text]

I understand that the problem is that the block is not being evaluated as code at the time I am appending it to saved-data-block. What can I do to save the string value to the text file in a block-like manner? Should I be doing something else to achieve this? Any comments/queries are welcome.

like image 971
KK. Avatar asked Feb 14 '13 18:02

KK.


People also ask

What are retention labels?

Retention labels help you retain what you need and delete what you don't at the item level (document or email). They are also used to declare an item as a record as part of a records management solution for your Microsoft 365 data.

How do I label a document before saving it?

On the Settings page, under Permissions and Management, select Apply label to items in this list or library. On the Apply Label page, select the drop-down box, then select the label that you want to apply. The label you select will be automatically applied to all new files added to the document library beginning now.

What is a label in Excel?

Labels and values. Entering data into a spreadsheet is just like typing in a word processing program, but you have to first click the cell in which you want the data to be placed before typing the data. All words describing the values (numbers) are called labels.


2 Answers

If you aren't required to specifically use reduce, compose can be a better way of calling out the parts you want to be "left alone". Only things in parentheses will be evaluated, everything else untouched. So for instance:

append/only saved-data-block compose [contact-name: (get-face contact-name)]

Compose is often the clearest way to express boilerplate with little parts noted that you want to be evaluated. Of course, it's good to understand reduce too.

like image 153
HostileFork says dont trust SE Avatar answered Oct 19 '22 11:10

HostileFork says dont trust SE


And here is another idea:

append/only saved-data-block repend [contact-name:] get-face contact-name 

This time contact-name: isn't reduced, so it stays a set-word!, and the value from the form element is appended.

Doesn't look nice with the double append, but saves on key-strokes.

like image 36
ingo Avatar answered Oct 19 '22 12:10

ingo