[REBOL] Using Rebol from within Notetab. Re:

2000-07-31 Thread jregent




> Add your own clipbook entries to mine for calling on Rebol 
scripts to
> process your text. For example, you can open a tab delimited 
text file
> exported from Excel. Select all the text. Click on "Tab 
delimited to block"
> and the text will be replaced with a rebol block version of the 
data. You
> can also go the other way.
> 
> Anyway, check it out at 
http://www.zipworld.com.au/~bhandley/rebol/
> 
> Have fun :)
> 
> Brett.
> 

---
REBOL[
Author: "Brett Handley"
Date: 17-July-2000
Purpose: "Load and export tables stored as text using a 
character as a column delimiter."
Comment: {Handles quoted strings. Returns a block of blocks.
  Each row being a block of strings that represent 
each cell.
  Works under version 2.3 of core.
 }
]

delimited-text-parser: make object! [
rows: none ; Internal variable
a-row: none ; Internal variable
cell-data: none ; Internal variable
data: none ; Internal variable

cell-delimiter: none
row-delimiter: "^/"
match-unquoted-data: none
initialise: func[][
match-unquoted-data: complement charset rejoin [cell-
delimiter {"} row-delimiter]
]
only-string: func[ s [any-string! none!] ][ either s [s][copy 
{}]]
unquoted-data-pattern: [
copy cell-data some match-unquoted-data
]
quoted-data-pattern: [
   (cell-data: copy {})
   {"} copy data to {"} {"} (append cell-data only-string 
data)
   any [
   {"} copy data to {"} {"} (append cell-data rejoin [{"} 
only-string data])
   ]
]
data-pattern: [ [quoted-data-pattern | unquoted-data-
pattern ] ]
cell-pattern: [
[ [ cell-delimiter (cell-data: none)] | [data-pattern opt 
cell-delimiter] ]
]
row-pattern: [
(a-row: make block! 1)
[
row-delimiter |
[
   some [ cell-pattern (append a-row only-string cell-
data) ]
   opt row-delimiter
]
]
]
delimited-text-pattern:[
(rows: make block! 10)
any [ row-pattern (append/only rows a-row)]
]
load-character-delimited: func[x [string!] /with a-char 
[char!]] [
cell-delimiter: to-string either with [a-char][tab]
initialise
if not parse/all x delimited-text-pattern 
[Print "Assumptions failed."]
rows
]

]

to-quoted-unquoted-string: function[x delimiter][do-special][
do-special: any [
find x delimiter
find x {"}
find x {'}
]
either do-special [
head insert append replace/all copy x {"} {""} {"} {"}
][
copy x
]
]

to-delimited: function[
x [block!]
delimiter [string!]
/table "Indicates that block is a table, seperate rows with 
newline."
][result-string][
either table [
result-string: make string! 1
if 0 < length? x [
append result-string to-delimited x/1 delimiter
]
for i 2 length? x 1 [
append result-string "^/"
append result-string to-delimited (pick x i) delimiter
]
result-string
][
result-string: make string! 1
if 0 < length? x [
append result-string to-quoted-unquoted-string (x/1) 
delimiter
]
for i 2 length? x 1 [
append result-string delimiter
append result-string to-quoted-unquoted-string (pick 
x i) delimiter
]
result-string
]

]

to-character-delimited: func [
x [block!]
delimiter [string!]
][
either 0 < length? x [
either block? x/1 [
to-delimited/table x delimiter
][
to-delimited x delimiter
]
][
copy {}
]
]

load-tab-delimited: func[x [string!]][delimited-text-parser/load-
character-delimited x]
load-comma-delimited: func[x [string!]][delimited-text-
parser/load-character-delimited/with x #","]
export-tab-delimited: func [x [block!]][ to-character-delimited 
x "^-"]
export-comma-delimited: func [x [block!]][ to-character-delimited 
x ","]



Objevujte Internet s http://www.centrum.cz
Založte si svuj mail na http://mail.centrum.cz




[REBOL] Using Rebol from within Notetab. Re:

2000-07-30 Thread jkinraid

[EMAIL PROTECTED] wrote:
> 
> I've created a web page with a few rebol scripts and in particular some
> support for using Rebol from within the Notetab text editor.
> 
> Things you can do:
> 
> Write a rebol expression in a notetab text file, select it and have the
> selected expression evaluted by Rebol, with the results replacing the
> selected text.
> 
> Add your own clipbook entries to mine for calling on Rebol scripts to
> process your text. For example, you can open a tab delimited text file
> exported from Excel. Select all the text. Click on "Tab delimited to block"
> and the text will be replaced with a rebol block version of the data. You
> can also go the other way.
> 
> Anyway, check it out at http://www.zipworld.com.au/~bhandley/rebol/

I also have some similar macros for the vim editor if anyone wants them.

Julian Kinraid




[REBOL] Using Rebol from within Notetab.

2000-07-30 Thread bhandley

I've created a web page with a few rebol scripts and in particular some
support for using Rebol from within the Notetab text editor.

Things you can do:

Write a rebol expression in a notetab text file, select it and have the
selected expression evaluted by Rebol, with the results replacing the
selected text.

Add your own clipbook entries to mine for calling on Rebol scripts to
process your text. For example, you can open a tab delimited text file
exported from Excel. Select all the text. Click on "Tab delimited to block"
and the text will be replaced with a rebol block version of the data. You
can also go the other way.

Anyway, check it out at http://www.zipworld.com.au/~bhandley/rebol/

Have fun :)

Brett.