r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[reblets] working reblets (50-100 lines or less)

Maxim
19-Mar-2009
[3x2]
rebol [
	title: "explore.r"
	version 1.0
	date: 2009-03-19
	author: "Maxim Olivier-Adlhoch"
	copyright: "2009(c)Maxim Olivier-Adlhoch"
	tested: "win xp"

 notes: "Add any dir to the dirs block.  options are self explanatory"
]

dirs: [
	%/C/ []
	%"/C/program files/" [expand]
	"%tmp%" [label "temp dir"]
	"" [ label "my documents"]
]

blk: []

explore-dir: func [path expand? /local cmd][

 call/shell rejoin [" explorer " either expand? ["/n,/e,"]["/n,"] 
 path ]
]

ctr: 1
foreach [item opts] dirs [
	ctr: ctr + 1
	expand?: found? find opts 'expand
	label: any [select opts 'label to-local-file item]
	append blk compose/deep [ 
		pad 20 
		(to-set-word setw: rejoin ["dir" ctr]) check (expand?) 
		pad 20 

  btn 200 left (label) [ explore-dir to-local-file item get in (to-word 
  setw) 'data ]
	]
	append blk 'return
]


view layout compose [across vtext right "expand?" vtext "folder" 
 return (blk)]
bug creep: parens disapeared for some strange reason...  replace 
in the above:


btn 200 left (label) [ explore-dir to-local-file item get in (to-word 
setw) 'data ]

with


btn 200 left (label) [ explore-dir (to-local-file item) get in (to-word 
setw) 'data ]
Ammon
1-Apr-2009
[5:last]
REBOL [
	File: %scramble.r
	Author: "Ammon Johnson"
	Email: [ammon-:-johnson-:-gmail-:-com]
	Version: 0.0.1
	History: [
		0.0.1 31-Mar-2009 "scrambles and descrambles code"
	]
]

scramble: context [
	words: []
	load-words: does [
		foreach word first system/words [
			add-word mold word
		]
	]
	add-word: func [
		word
		/local chars length
	][
		chars: charset word
		unless found? find words chars [repend words [chars copy []]]

  unless found? find words/:chars length: length? word [repend words/:chars 
  [length copy []]]
		length: select words/:chars length
		unless found? find length word [insert tail length word]
		word
	]
	get-word: func [
		word
		/local chars length
	][
		chars: charset word
		unless chars: select words chars [return "UNKNOWN"]
		unless length: select chars length? word [return "UNKNOWN"]
		random/only length
	]
	scramble: func [
		txt
		/local result
	][
		result: parse/all txt " "
		forall result [

   unless empty? trim copy result/1 [change result random add-word result/1]
		]
		form result
	]
	
	descramble: func [
		txt
		/local result
	][
		result: parse/all txt " "
		forall result [

   unless empty? trim copy result/1 [change result get-word result/1]
		]
		form result
	]
]