Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / classes / gadgets / texteditor / demo / rexx / ImageDimensions.TEd
blob49879cd6599a0f899fb6b5c868ced11f092487de
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  **/
15 /* Please customize this line */
16 Visage = "Duff's:Graphics/Visage"
18 /* The rest should work without your interference :-) */
19 Options Results
21 Address 'TEXTEDITOR-DEMO.1'
23 Path    = 'Data:Homepage'
24 GetCursor Column;  CursorX = RESULT
25 GetCursor Line;    LineNr  = RESULT
26 GetLine;           Line    = RESULT
28 EndTag    = Right(Line, Length(Line)-CursorX)
29 EndTagPos = Pos(">", EndTag)
31 If(EndTagPos > 0) Then
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)
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
51                         If(Right(Path, 1) = ':') Then
52                                         File = Path || FileName
53                         Else    File = Path || '/' || FileName
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')
64                                 Parse Var Info width 'x' height 'x' rest
66                                 GotoLine   LineNr
67             GotoColumn Length(Line)-StartTagPos+1
68                                 Text '" Width=' || width || ' Height=' || height || '"'
69                         End
70                 End
71         End
72 End