home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Programming / RxMUI / Examples / p2s.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2001-05-24  |  1.1 KB  |  60 lines

  1. /*
  2. Read an image so that its result
  3. may be used as Source for Picture class
  4. */
  5.  
  6. l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  7. if AddLibrary("rxmui.library")~=0 then exit
  8.  
  9. if ~Open("STDERR","CONSOLE:") then stderr="STDOUT"
  10.  
  11. if ~ReadArgs("FROM/A,TO") then call failure
  12.  
  13. if parm.1.flag then do
  14.     if ~Open("OUT",parm.1.value,"w") then call failure
  15. end
  16. else out = "STDOUT"
  17.  
  18. st=statef(parm.0.value)
  19. if st="" then call failure
  20. if word(st,1)~="FILE" then do
  21.     call SetIoErr(212)
  22.     call failure
  23. end
  24. s=word(st,2)
  25. if s>32767 then do
  26.     call info(programname(noext)": file '"parm.0.value"'is too large")
  27.     exit
  28. end
  29.  
  30. bm.sourcetype="file"
  31. bm.source=parm.0.value
  32. if NewObj("picture","bm")>0 then call failure
  33.  
  34. pic=readfile(parm.0.value)
  35. if pic="" then call failure
  36.  
  37. msg="Reading file '"parm.0.value"' ("length(pic)" bytes)"
  38. if parm.1.flag then msg=msg "to file '"parm.1.value"'"
  39. call info msg
  40.  
  41. s=31
  42. do while pic~=""
  43.     parse var pic b +s pic
  44.     b=c2x(b)
  45.     if s=31 then b=' "'||b
  46.     if pic = "" then b=b||'"x'
  47.     call writeln(out,b)
  48.     s=32
  49. end
  50. exit
  51.  
  52. failure:
  53.     call PrintFault()
  54.     exit
  55.  
  56. info:
  57. parse arg msg
  58.     call writeln(stderr,msg)
  59.     return
  60.