home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / pascal / 4822 < prev    next >
Encoding:
Text File  |  1992-08-12  |  2.5 KB  |  94 lines

  1. Xref: sparky comp.lang.pascal:4822 comp.lang.c:12225 comp.lang.c++:12269
  2. Path: sparky!uunet!olivea!decwrl!sdd.hp.com!usc!noiro.acs.uci.edu!beckman.com!dn66!a_rubin
  3. From: a_rubin@dsg4.dse.beckman.com (Arthur Rubin)
  4. Newsgroups: comp.lang.pascal,comp.lang.c,comp.lang.c++
  5. Subject: Re: Pascal to C and Assembly
  6. Message-ID: <a_rubin.713639814@dn66>
  7. Date: 12 Aug 92 17:16:54 GMT
  8. References: <1992Aug7.164932.15243@cs.mun.ca>
  9. Lines: 82
  10. Nntp-Posting-Host: dn66.dse.beckman.com
  11.  
  12. In <1992Aug7.164932.15243@cs.mun.ca> jodyc@garfield.cs.mun.ca (Jody R. Cairns) writes:
  13.  
  14.  
  15. >Hello folks,
  16.  
  17. >  I have a request: could someone please translate the following Turbo Pascal
  18. >  code to C and assembly language. I'd like the C version to be compatible 
  19. >  with both Borland's and Microsoft's compilers, and the assembly version to
  20. >  be compatible with Borland's TASM and Microsoft's MASM.  I realize the
  21. >  assembly language is a bit much, so I don't expect to get that anytime
  22. >  soon (if at all).
  23.  
  24. >  Please e-mail source code to: jodyc@cs.mun.ca
  25.  
  26. >(************************************************************)
  27.  
  28. >{$A+,B-,D-,L-,I-,R-,S-,V-}
  29. >{$M 1024,0,0}
  30.  
  31. >TYPE
  32. >  DirStr = string[67];
  33.  
  34. >VAR
  35. > Str: DirStr;
  36. > I  : word;
  37.  
  38. >BEGIN
  39. >  Str:=ParamStr(1);
  40.  
  41. >  FOR I:=1 TO length(Str) DO
  42. >    Str[I]:=upcase(Str[I]);
  43.  
  44. >  ChDir(Str);
  45. >  IF IOResult <> 0 THEN
  46. >    IF Str = '' THEN
  47. >      ChDir('C:\')
  48. >    ELSE IF Str = 'DOS' THEN 
  49. >      ChDir('C:\DOS')
  50. >    ELSE IF Str = 'BIN' THEN
  51. >      ChDir('C:\DOS\BIN')
  52. >    ELSE 
  53. >      writeln('ERROR: Invalid directory.');
  54.  
  55. >  IF IOResult <> 0 THEN 
  56. >    writeln('ERROR: Invalid directory.')
  57. >END.
  58. ----------------Microsoft C--------------
  59.  
  60. #include <stdio.h>
  61. #include <string.h>
  62. #include <direct.h> /* chdir */
  63. main(int argc,char * * argv)
  64. {
  65.     char * str;
  66.     int result;
  67.     str = strupr(strdup(argv[1]));
  68.  
  69.     if (result=chdir(argv[1])) {
  70.         if (!strcmp(argv[1],"")) {
  71.             result = chdir("C:\\");
  72.         }
  73.         else if (!strcmp(argv[1],"DOS") {
  74.             result = chdir("C:\\DOS")
  75.         }
  76.         else if (!strcmp(argv[1],"BIN") {
  77.             result = chdir("C:\\DOS\\BIN")
  78.         }
  79.      }
  80.      if (result) {
  81.          puts ("ERROR: Invalid directory.")
  82.      }
  83. }
  84.  
  85.  
  86.  
  87.  
  88.  
  89. --
  90. Arthur L. Rubin: a_rubin@dsg4.dse.beckman.com (work) Beckman Instruments/Brea
  91. 216-5888@mcimail.com 70707.453@compuserve.com arthur@pnet01.cts.com (personal)
  92. My opinions are my own, and do not represent those of my employer.
  93. Our news system is unstable; if you want to be sure I see a post, mail it.
  94.