home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / dos.swg / 0072_TRUENAME (BASM).pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-08-24  |  1.1 KB  |  49 lines

  1.  
  2.  
  3. program TName;  { to test the TrueName function }
  4.  
  5. function TrueName(var P: string): string; assembler;
  6. { returns TrueName just like the DOS command does }
  7. { if error, returns a zero length string }
  8. { will probably crash for DOS versions < 3.0 }
  9. { donated to the Public Domain by Björn Felten @ 2:203/208 }
  10. asm
  11.    push  ds
  12.    lds   si,P
  13. @strip:
  14.    inc   si     { skip length byte ... }
  15.    cmp   byte ptr [si],' '
  16.    jle   @strip { ... and trailing white space }
  17.  
  18.    les   di,@Result
  19.    inc   di     { leave room for byte count }
  20.    mov   ah,60h { undocumented DOS call }
  21.    int   21h
  22.    pop   ds
  23.    jc    @error
  24.  
  25.    mov   cx,80  { convert ASCIZ to Pascal string }
  26.    xor   ax,ax
  27.    repnz scasb  { find trailing zero }
  28.    mov   ax,80
  29.    sub   ax,cx  { get length byte }
  30.    jmp   @ret
  31.  
  32. @error:
  33.    xor   ax,ax  { return zero length string }
  34.  
  35. @ret:
  36.    les   di,@Result
  37.    stosb
  38. end;
  39.  
  40.  
  41. var S:string;
  42. begin
  43.    S:=paramstr(1);
  44.    if paramcount<>1 then
  45.       writeln('Usage: tname <filename>')
  46.    else
  47.       writeln('TrueName of ',S,' is ',TrueName(S))
  48. end.
  49.