Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: ?unset?

From: ingo:2b1 at: 3-Apr-2002 10:58

Hi Louis, your problem is, that you _print_ from within a 'print statement, and that doesn't work (as you've figured yourself by now).
>> print ["123" pad 10 "456"]
123 ?unset? What happened here is, that 'print first found a value ("123") and then a function, so, to be able to know what to print, 'print _first_ executed the 'pad function. 'Pad used 10 and "456" as it's parameters and printed seven spaces. Then it returned the last value. Given that 'prin was the last part of 'pad, and that 'prin doesn't return a value, the value returned by 'pad was unset, too. Now 'print was ready to do its job: print the value "123", a space, and the value returned by 'pad, which was unset. Now, you have to change your function to either print everything: pad1: func [ form-length val ] [ loop form-length - length? to-string val [prin " "] prin val ]
>> prin "123" pad1 10 "456" print ""
123 456 or to just return the padded value: pad2: func [ form-length val /local ret ] [ ret: make string! 20 loop form-length - length? to-string val [insert ret " "] append ret val ]
>> print ["123" pad2 10 "456"]
123 456 I hope that shed a little light on the mistery ... Ingo Am Die, 2002-04-02 um 21.43 schrieb Dr. Louis A. Turk: