Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!astroatc.UUCP!tenaglia From: tenaglia@astroatc.UUCP (Chris Tenaglia) Newsgroups: comp.lang.icon Subject: (none) Message-ID: <8908031958.AA11677@astroatc.UUCP> Date: 3 Aug 89 19:58:15 GMT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 71 Dear Icon-Group, Here's a rather curious utility. It's an ASCII/EBCDIC translator. Some of us occasionally get data tapes from IBM mainframes. Unix does supply a dd utility as a translator, but not MS-DOS or VMS. So I constructed this one. You may just find the translate tables useful of themselves. The program is run as a filter. ebasc -a file2 is ebcdic to ascii. ebasc -e file2 is ascii to ebcdic. You may have noticed some special 'metacomments'. In a future submission I will submit an Icon program pretty printer that makes use of them. Yours truly, Chris Tenaglia Astronautics Corporation of America 4115 N. Teutonia Avenue Milwaukee, Wi 53209 USA (414) 447-8200 X-421 Our motto : Icon do it! #TITLE EBASC : ASCII/EBCDIC TRANSLATOR #SUB USAGE : ICONX EBASC -OPTION STDOUT #EJECT ############################################################################# # # # EBASC.ICN 3/24/88 BY TENAGLIA # # # ############################################################################# procedure main(option) asc := string(&cset) ebc := "\000\001\002\003\234\011\206\177\227\215\216\013\014\015\016\017"|| "\020\021\022\023\235\205\010\207\030\031\222\217\034\035\036\037"|| "\200\201\202\203\204\012\027\033\210\211\212\213\214\005\006\007"|| "\220\221\026\223\224\225\226\004\230\231\232\233\024\025\236\032"|| "\040\240\241\242\243\244\245\246\247\250\133\056\074\050\053\041"|| "\046\251\252\253\254\255\256\257\260\261\135\044\052\051\073\136"|| "\055\057\262\263\264\265\266\267\270\271\174\054\045\137\076\077"|| "\272\273\274\275\276\277\300\301\302\140\072\043\100\047\075\042"|| "\303\141\142\143\144\145\146\147\150\151\304\305\306\307\310\311"|| "\312\152\153\154\155\156\157\160\161\162\313\314\315\316\317\320"|| "\321\176\163\164\165\166\167\170\171\172\322\323\324\325\326\327"|| "\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347"|| "\173\101\102\103\104\105\106\107\110\111\350\351\352\353\354\355"|| "\175\112\113\114\115\116\117\120\121\122\356\357\360\361\362\363"|| "\134\237\123\124\125\126\127\130\131\132\364\365\366\367\370\371"|| "\060\061\062\063\064\065\066\067\070\071\372\373\374\375\376\377" (method := option[1]) | help() case method of { "-a" : while write(map(read(),asc,ebc)) #ebcdic to ascii "-e" : while write(map(read(),ebc,asc)) #ascii to ebcdic default : help() #on line help (default) } end procedure help() if find("nix",map(&host)) then # open screen for vdu := open("/dev/tty","w") # online help. It if find("dos",map(&host)) then # recognizes Unix vdu := open("cons","w") else vdu := open("tt:","b") # DOS & VMS. write(vdu,"USAGE : iconx ebasc -option stdout") write(vdu,"\e[1;7m*** Translate between ascii and ebcdic coded data ***\e[m") write(vdu,"\e[1;7m-a Option translates ebcdic to ascii. \e[m") write(vdu,"\e[1;7m-e Option translates ascii to ebcdic. \e[m") write(vdu,"\e[1;7m-h Option outputs this help paragraph. \e[m") write(vdu,"\e[1;7mstdout Specify output file using redirector symbol. \e[m") stop() end