home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / basic / mxadstf.for < prev    next >
Encoding:
Text File  |  1989-11-09  |  1.6 KB  |  49 lines

  1. C ******************** ADDSTRING  *********************
  2. C This program is in file MXADSTF.FOR
  3. C Declare interface to Stringassign subprogram. The pointer fields are
  4. C declared INTEGER*4, so that different types of far pointers can be
  5. C passed without conflict. The INTEGER*4 fields are essentially generic
  6. C pointers. [VALUE] must be specified, or FORTRAN will pass pointers to
  7. C pointers. INTEGER*2 also passed by [VALUE], to be consistent with
  8. C declaration of Stringassign.
  9. C
  10.        INTERFACE TO SUBROUTINE STRASG [ALIAS:'STRINGASSIGN'] (S,SL,D,DL)
  11.        INTEGER*4 S [VALUE]
  12.        INTEGER*2 SL [VALUE]
  13.        INTEGER*4 D [VALUE]
  14.        INTEGER*2 DL [VALUE]
  15.        END
  16. C
  17. C Declare heading of Addstring function in the same way as above: the
  18. C pointer fields are INTEGER*4
  19. C
  20.        INTEGER*2 FUNCTION ADDSTR [ALIAS:'ADDSTRING'] (S1,S1LEN,S2,S2LEN)
  21.        INTEGER*4 S1 [VALUE]
  22.        INTEGER*2 S1LEN [VALUE]
  23.        INTEGER*4 S2 [VALUE]
  24.        INTEGER*2 S2LEN [VALUE]
  25. C
  26. C Local parameters TS1, TS2, and BIGSTR are temporary strings. STRDES is
  27. C a four-byte object into which Stringassign will put BASIC string
  28. C descriptor.
  29. C
  30.        CHARACTER*50 TS1, TS2
  31.        CHARACTER*100 BIGSTR
  32.        INTEGER*4 STRDES
  33.  
  34.     TS1 = " "
  35.     TS2 = " "
  36.     STRDES = 0
  37.  
  38. C
  39. C Use the LOCFAR function to take the far address of data. LOCFAR returns
  40. C a value of type INTEGER*4.
  41. C
  42.        CALL STRASG (S1, 0, LOCFAR(TS1), S1LEN)
  43.        CALL STRASG (S2, 0, LOCFAR(TS2), S2LEN)
  44.        BIGSTR = TS1(1:S1LEN) // TS2(1:S2LEN)
  45.        CALL STRASG (LOCFAR(BIGSTR), S1LEN+S2LEN, LOCFAR(STRDES), 0)
  46.        ADDSTR = LOC(STRDES)
  47.        RETURN
  48.        END
  49.