home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / MUI / MCC_TextEditor / Demos / Rexx / ImageDimensions.TEd < prev    next >
Encoding:
Text File  |  1997-09-30  |  1.8 KB  |  73 lines

  1. /**
  2.  **  ImageDimensions.CEd V1.0 (31-Aug-97) For CygnusEd & Visage
  3.  **
  4.  **  This script will paste the width and height for the image
  5.  **  specified within an <IMG> tag.
  6.  **  Bind it to a hotkey, and press that key while
  7.  **  the cursor is placed inside an <Img Src=...> tag.
  8.  **  This doesn't work for pictures given an absolute path,
  9.  **  like http://... but you probably knew that ;^)
  10.  **
  11.  **
  12.  **  For feedback write Allan Odgaard <Duff@DIKU.DK>
  13.  **/
  14.  
  15. /* Please customize this line */
  16. Visage = "Duff's:Graphics/Visage"
  17.  
  18. /* The rest should work without your interference :-) */
  19. Options Results
  20.  
  21. Address 'TEXTEDITOR-DEMO.1'
  22.  
  23. Path    = 'Data:Homepage'
  24. GetCursor Column;  CursorX = RESULT
  25. GetCursor Line;    LineNr  = RESULT
  26. GetLine;           Line    = RESULT
  27.  
  28. EndTag    = Right(Line, Length(Line)-CursorX)
  29. EndTagPos = Pos(">", EndTag)
  30.  
  31. If(EndTagPos > 0) Then
  32. Do
  33.     Line = Upper(Left(Line, EndTagPos+CursorX))
  34.     StartTagPos = Pos("GMI<", Reverse(Line))
  35.     If(StartTagPos > 0) Then
  36.     Do
  37.         Tag        = Right(Line, StartTagPos+3)
  38.         PicturePos = Pos("SRC=", Tag)
  39.         If(PicturePos > 0) Then
  40.         Do
  41.             Name = Right(Tag, Length(Tag)-PicturePos-3)
  42.  
  43.             If(Left(Name, 1) = '"') Then
  44.                 Parse Var Name '"' FileName '"' rest
  45.             Else
  46.             Do
  47.                 Parse Var Name FileName '>' rest
  48.                 Parse Var FileName FileName ' ' rest
  49.             End
  50.  
  51.             If(Right(Path, 1) = ':') Then
  52.                     File = Path || FileName
  53.             Else    File = Path || '/' || FileName
  54.  
  55.             Address Command Visage '>T:ImgDimensions "'File'" Info'
  56.             If(RC = 0) Then
  57.             Do
  58.                 Open('Size','T:ImgDimensions','Read')
  59.                 Info = ReadLn('Size')
  60.                 Info = ReadLn('Size')
  61.                 Info = Right(Info, Length(Info)-10)
  62.                 Close('Size')
  63.  
  64.                 Parse Var Info width 'x' height 'x' rest
  65.  
  66.                 GotoLine   LineNr
  67.             GotoColumn Length(Line)-StartTagPos+1
  68.                 Text '" Width=' || width || ' Height=' || height || '"'
  69.             End
  70.         End
  71.     End
  72. End
  73.