Rebol Programming/do-boot

From Wikibooks, open books for an open world
Jump to navigation Jump to search

USAGE:[edit | edit source]

DO-BOOT target args dependent 

DESCRIPTION:[edit | edit source]

Does a value only if it and its file (URL) and it's dependent exists.

DO-BOOT is a function value.

ARGUMENTS[edit | edit source]

  • target -- (Type: any)
  • args -- (Type: any)
  • dependent -- (Type: any)

SOURCE CODE[edit | edit source]

do-boot: func [
    {Does a value only if it and its file (URL) and it's dependent exists.} 
    target 
    args 
    dependent 
    /local check dir
][
    check: func [target /local tmp] [
        if exists? target [return make file! 1] 
        if exists? system/options/home/:target [return system/options/home] 
        none
    ] 
    if target [
        if dependent [dir: check dependent] 
        if none? dir [dir: check target] 
        if dir [
            dir: append copy dir target 
            if exists? dir [do/args dir args return true]
        ]
    ] 
    false
]