MORE REBOL/Power-Tools

 
Here's some more REBOL/Power-Tools DE-SPACE & RE-SPACE

These functions remove & replace all whitespace characters
from a string! or file! 
White-space is interchanged for Hex %20 value just like
in a REBOL file path!

Very useful for PARSING purposes, enables string values to 
remain intact whilst separating other values by whitespace.

Anyway here's the functions;


DE-SPACE: func [ "REPLACES ALL WHITE-SPACE CHARACTERS WITH A HEX 
VALUE" target [ string! file!]] [ if (type? target) = file! [
 target: read target] replace/all target " " "%20"]


RE-SPACE: func [ "REPLACES ALL HEX %20 VALUES WITH WHITE-SPACE 
CHARACTER" target [ string! file!]] [ if (type? target) = file! [
 target: read target] replace/all target "%20" " "]


here's some examples;

>> a: de-space " this    silly   stupid   string  "
== {%20this%20%20%20%20silly%20%20%20stupid%20%20%20string%20%20}
>> a
== {%20this%20%20%20%20silly%20%20%20stupid%20%20%20string%20%20}
>> re-space a
== " this    silly   stupid   string  "
>> parse a none
== ["this" "silly" "stupid" "string"]
>> parse de-space a none
== [{%20this%20%20%20%20silly%20%20%20stupid%20%20%20string%20%20}]
>> de-space %readme.txt
== {GUIcon%20(aka%20Console)%20Program%20for%20Win32%20platforms,%
200.1.
3%20(20-Jan-2001)

This%20is%20a%20readme%20file%20that%20e...
>> re-space de-space %readme.txt
== {GUIcon (aka Console) Program for Win32 platforms, 0.1.3 (20-Jan-
2001
)

This is a readme file that everyone should read first!

...
>>

; README.txt file courtesy of our GEO MASSAR


 
Here's a function that return an ASCII value or block of values
for a char! string! or file! { note file contents )

ASCII: func [ "RETURNS ASCII INTEGER VALUES" value [ char! string! 
file! ]] [

if (type? value) = file! [value: read value] 

if (type? value) = char! [ return to-integer value] 

count: length? value
value-block: [] clear value-block

loop count [ append value-block to-integer pick value 1 value: next 
value ]

return value-block 

]

some examples;

>> ascii #"A"
== 65
>> ascii "A"
== [65]
>> ascii "APPLES"
== [65 80 80 76 69 83]
>> ascii %./guicon013/readme.txt
== [71 85 73 99 111 110 32 40 97 107 97 32 67 111 110 115 111 108 101 
41
 32 80 114 111 103 114 97 109 32 102 111 114 32 87 105 110 ...
>> 


Feel free to add your own Power Tools & Functions.
 
still lots more to come, 

PS -- Ralph Roberts, glad you liked my directory functions, thank you for 
your kind words, it feels good to feel like I've done something good for a 
change.

Sorry everybody for the big spat over the last few days, I don't like or want 
religious wars in REBOL either!.

Mark Dickson
 
-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to