07 January 2022, 20:17 | #1 |
Registered User
Join Date: Jun 2020
Location: Germany
Posts: 378
|
How to get specific values from output?
Hello,
I'm searching for a way to get the snapped icon positions (x/y) into variables to use them in a script. The script uses http://aminet.net/package/util/cli/MoveIcon to set a new position. Code:
.KEY ICON/A ; $VER: PosIcon 1.2 (07.Jan.22) ; Simple MoveIcon GUI for selected icon SET xpos `REQUESTSTRING TITLE "X (Left) Position" BODY="Enter new X (Left) Position" PATTERN="10"` SET ypos `REQUESTSTRING TITLE "Y (Top) Position" BODY="Enter new Y (Top) Position" PATTERN="10"` IF EXISTS "<ICON>.info" MoveIcon NAME "<ICON>" X ${xpos} Y ${ypos} ELSE MoveIcon NAME "<ICON>disk" X ${xpos} Y ${ypos} ENDIF UNSET xpos UNSET ypos So far I have found two programs which can show the current position. One is http://aminet.net/package/util/cli/DoIcon17 and the output is: Code:
Icontype: DISK Icon-position: left edge = 82 and top edge = 5 Icon-dimensions: width = 57 and height = 39 Window-position: left edge = 203 and top edge = 224 Window-dimensions: width = 394 and height = 153 Drawer window is set to show only files with an icon. Drawer contents is listed as ICON. Defaulttool: SYS:System/DiskCopy Depth: 3 bit-planes Highlight-method: IMAGE Code:
Name: sys:disk Type: Standard SS: 4096 IT: Disk BP: 3,3 SZ: x= 82, y= 5, w= 57, h= 39 DT: (YES) SYS:System/DiskCopy TT: (NO) I know there are programs like grep, but I'm not smart enough to figure out how to use them. If anyone could help me out with this (preferably with the output from ProcessIcon because I already use it for other stuff.) or has an alternative solution, I would be very happy. |
07 January 2022, 20:26 | #2 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
ProcessIcon has source, is it an option to adapt that to give you what you need?
|
07 January 2022, 21:30 | #3 |
Registered User
Join Date: Jun 2020
Location: Germany
Posts: 378
|
Maybe, but I can't do it. I have no programming skills.
Although having a program which could do something like: Code:
GetPos "icon.info" X GetPos "icon.info" Y |
07 January 2022, 21:36 | #4 |
Registered User
Join Date: Sep 2014
Location: Poland
Posts: 175
|
Adapt this script according to your needs.
Code:
/* get icon X and Y position */ PARSE ARG file IF file="" | file="?" THEN DO SAY 'Usage: GetIconXY <file>' EXIT 0 END file=STRIP(file,B,'"') IF OPEN('i',file,R) THEN DO CALL SEEK('i',60,B) /* 60=$3C an magic number! */ x=READCH('i',2) CALL READCH('i',2) /* dummy read = skip next 2 bytes */ y=READCH('i',2) SAY "x="C2D(x)", y="C2D(y) CALL CLOSE('i') END ELSE DO SAY "Error! Can't open:" file EXIT 20 END |
07 January 2022, 22:45 | #5 |
Registered User
Join Date: Jun 2020
Location: Germany
Posts: 378
|
Looks like I need to learn AREXX first. I appreciate the help but meanwhile I found http://aminet.net/package/util/cli/ksc_Cut which was mentioned here in a different thread and I combined it with this http://aminet.net/package/util/cli/sect to reduce the output to a single line first and then cut out the values. Compared to the AREXX script it is probably a bit extreme, but it works.
Code:
.KEY ICON/A ; $VER: PosIcon 1.2 (07.Jan.22) ; Simple MoveIcon GUI for selected icon ProcessIcon <ICON> VIEW >T:GetPos.1 ; Full Output Sect -s6 -l1 T:GetPos.1 >T:GetPos.2 ; Extract position line Cut FROM T:GetPos.2 TO T:GetPos.x START 8 LENGTH 3 ; Get X position SET oldx `TYPE T:GetPos.x` ; Set X variable Cut FROM T:GetPos.2 TO T:GetPos.y START 15 LENGTH 3 ; Get Y position SET oldy `TYPE T:GetPos.y` ; Set Y variable SET xpos `REQUESTSTRING TITLE "X (Left) Position" BODY="Enter new X (Left) Position" PATTERN="${oldx}"` ; Request new X, defaults to old X SET ypos `REQUESTSTRING TITLE "Y (Top) Position" BODY="Enter new Y (Top) Position" PATTERN="${oldy}"` ; Request new Y, defaults to old Y ; check if file is a disk icon. Required for MoveIcon IF EXISTS "<ICON>.info" MoveIcon NAME "<ICON>" X ${xpos} Y ${ypos} ELSE MoveIcon NAME "<ICON>disk" X ${xpos} Y ${ypos} ENDIF ;clean up UNSET oldx UNSET oldy UNSET xpos UNSET ypos DELETE >NIL: T:GetPos#? |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
SetPeriod does not seem to like values I am inputting | Amiga1992 | Coders. Blitz Basic | 8 | 10 March 2021 00:28 |
Default display values | chip | support.WinUAE | 6 | 06 January 2018 14:00 |
Finegrain_cpu_speed values | hexaae | support.WinUAE | 2 | 14 August 2016 14:36 |
Discretizing / Normalizing Values in C/C++ | Zetr0 | Coders. General | 4 | 04 December 2006 09:29 |
|
|