home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / 3_1SWTOO.DMS / in.adf / wack.lha / demos / ShowMember.wack < prev    next >
Encoding:
Text File  |  1993-09-10  |  1.7 KB  |  74 lines

  1. /* ShowMember.wack
  2.  *
  3.  * (c) Copyright 1992-1993 Commodore-Amiga, Inc.  All rights reserved.
  4.  *
  5.  * This software is provided as-is and is subject to change; no warranties
  6.  * are made.  All use is at your own risk.  No liability or responsibility
  7.  * is assumed.
  8.  *
  9.  * This script considers the current or specified address to be a
  10.  * structure of the type you specify, and displays up to a long word
  11.  * of the specified member.  That is, if the specified member is a
  12.  * byte, word, long-word, or pointer, then its value is shown.  If
  13.  * the member is an embedded structure, then the first long word
  14.  * of the structure's contents is shown.
  15.  *
  16.  * Sets SpareAddress to point at the address of the member.
  17.  *
  18.  * Syntax: ShowMember structure member [address]
  19.  *
  20.  * Binding: bindrx showmember ShowMember
  21.  *
  22.  */
  23.  
  24. options results
  25. if ( arg() > 0 ) then
  26. DO
  27.     argline = arg(1)
  28.     parse var argline structure" "member" "address
  29.     structure = strip(structure)
  30.     member = strip(member)
  31.     address = strip(address)
  32.     if ( ( structure = "" ) | ( member = "" ) ) then
  33.     DO
  34.         'Print Bad syntax'
  35.         exit
  36.     END
  37.     if ( address = "" ) then
  38.     DO
  39.         CurrentAddr
  40.         address = result
  41.     END
  42.     call StructureOffset.rexx structure member
  43.     if ( datatype(left(result,4),'X') ) then
  44.     DO
  45.         offset = left(result,4)
  46.         size = strip(substr(result,5,4))
  47.         member = substr(result,9)
  48.         memberaddress = d2x(x2d(address)+x2d(offset))
  49.         if ( size = 1 ) then
  50.         DO
  51.             readbyte memberaddress
  52.         END
  53.         else if ( size = 2 ) then
  54.         DO
  55.             readword memberaddress
  56.         END
  57.         else
  58.         DO
  59.             readlong memberaddress
  60.         END
  61.         contents = result
  62.         Print structure'.'member' (at 'address'+'offset' = 'memberaddress') =' contents
  63.         SpareAddr memberaddress
  64.     END
  65.     else
  66.     DO
  67.         Print result
  68.     END
  69. END
  70. else
  71. DO
  72.     'Print Bad syntax'
  73. END
  74.