Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
REBOL 1.27 KB | None | 0 0
  1. Red [
  2.     Title:      "Find specific values in OS PATH"
  3.     Author:     "Arie van Wingerden"
  4.     Version:    1.0
  5.     Date:           "2017-07-25"
  6.     Needs:      'view
  7. ]
  8.  
  9. osdelim: ":"
  10. if system/build/config/os = 'windows [
  11.     osdelim: ";"
  12. ]
  13. list: split get-env "path" osdelim
  14.  
  15. process: function [arg] [
  16.     result: make block! 20
  17.     if empty? arg [
  18.         repeat i length? list [append result rejoin [pad/left i 4 "  " list/:i]]
  19.         i_t/text: "Now displaying all components of PATH variable"
  20.         return result
  21.     ]
  22.     arg: lowercase arg
  23.     i: 0
  24.     foreach elem list [
  25.         if find elem arg [
  26.             i: i + 1
  27.             append result rejoin [pad/left i 4 "  " elem]
  28.         ]
  29.     ]
  30.     either empty? result [
  31.         i_t/text: rejoin[{No match found for string "} arg {" in the PATH variable}]
  32.     ] [
  33.         i_t/text: rejoin[{Now displaying components of PATH variable containing string "} arg {"}]
  34.     ]
  35.     result
  36. ]
  37.  
  38. view [
  39.     title "Find specific values in OS PATH"
  40.     below
  41.     q_t: text 800x15 "Enter search string:"
  42.     a_t: field 800 focus on-enter [r_t/data: process a_t/text]
  43.     across
  44.     button "Search" [r_t/data: process a_t/text]
  45.     button "Clear search" [a_t/data: "" r_t/data: process ""]
  46.     button "Quit" [quit]
  47.     return
  48.   below
  49.   i_t: text "Results" 800x15
  50.     r_t: text-list 800x400 font-name "Courier new" []
  51.     do [process "" r_t/data: process a_t/text]
  52. ]
  53.  
  54. quit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement