Hi Rebols
in the original post was an error left, it didn't work
on words without value, now the Value? test has been
moved to the correct place.
help: func [
"Prints information about words and values."
'word [any-type!]
/local value args item refmode types
][
if unset? get/any 'word [
print trim/auto {
^-^-^-^-The help function provides a simple way to get
^-^-^-^-information about words and values. To use it
^-^-^-^-supply a word or value as its argument:
^-^-^-^-
^-^-^-^-^-help insert
^-^-^-^-In addition to help, these other words provide
^-^-^-^-information about the REBOL language:
^-^-^-^-
^-^-^-^-^-about - for general info
^-^-^-^-^-usage - for the command line arguments
^-^-^-^-^-license - for the terms of user license
^-^-^-^-^-source func - print source for given function
^-^-^-^-
^-^-^-^-For more information, see the user guides.
^-^-^-}
exit
]
; \/ \/ \/ start changes by iho
if path? :word [
use [obj parts i j] [
i: 2
parts: parse mold :word "/"
if error? try [obj: get to-word first parts] [
print ["Path:" :word "not found"]
exit
]
while [all [object? :obj i <= length? parts] ] [
either not error? try [obj: get in obj to-word pick parts i] [
++ i
] [
break
]
]
pth: first parts
for j 2 i - 1 1 [
append pth rejoin ["/" pick parts j ]
]
prin rejoin [{Valid subpath "} pth]
either function? :obj [
print {" is function:^/}
help obj
][
either object? :obj [
print {" is:^/}
help obj
] [
print {"^/}
help obj
]
]
]
exit
]
if not value? word [
print ["No information on" word "(word has no value)"]
exit
]
if object? get :word [
use [wrd hlp] [
print "Is object with fields:"
foreach wrd next first get word [
either function? get in get word wrd [
print [wrd ": func" either string? hlp: first third get in get word
wrd [
mold first parse/all hlp "^/"][""]]
] [
print [wrd ": " type? get in get word wrd]
]
]
exit
]
]
; /\ /\ /\ end changes by iho
if not word? :word [
print [mold word "is" type? word]
exit
]
value: get word
if not any-function? :value [
print [mold word "is" type? word "of value:" mold value]
exit
]
args: third :value
refmode: false
either string? pick args 1 [
print first args args: next args
] [
print "(undocumented)"
]
if block? pick args 1 [
print "Attributes:"
item: first args
args: next args
while [not tail? item] [
value: first item
item: next item
if any-word? value [
prin [" " value "-- "]
if string? pick item 1 [prin first item item: next item]
print ""
]
]
]
if tail? args [exit]
print "Arguments:"
while [not tail? args] [
item: first args
args: next args
if (mold item) = "/local" [break]
if all [refinement? item not refmode] [
print "Refinements:"
refmode: true
]
either refinement? item [
prin [" " mold item]
if string? pick args 1 [prin [" --" first args] args: next args]
print ""
] [
if any-word? item [
if refmode [prin " "]
prin [" " item "-- "]
types: if block? pick args 1 [args: next args first back args]
if string? pick args 1 [prin first args args: next args]
if types [prin rejoin [" (" types ")"]]
print ""
]
]
]
exit
]
regards,
Ingo
-- _ . _
ingo@)|_ /| _| _ <We ARE all ONE www._|_o _ _ ._ _
www./_|_) |o(_|(/_ We ARE all FREE> ingo@| |(_|o(_)| (_|
._| ._|