English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System > Coders. Scripting

 
 
Thread Tools
Old 07 January 2022, 20:17   #1
EctoOne
Registered User
 
EctoOne's Avatar
 
Join Date: Jun 2020
Location: Germany
Posts: 370
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
The annoying part is that I have to use another program to get the current position first, remember it.

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
The other one is http://aminet.net/package/util/wb/ProcessIcon with the output:
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)
In this case the x/y position is 82/5.
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.
EctoOne is offline  
Old 07 January 2022, 20:26   #2
deimos
It's coming back!
 
deimos's Avatar
 
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?
deimos is offline  
Old 07 January 2022, 21:30   #3
EctoOne
Registered User
 
EctoOne's Avatar
 
Join Date: Jun 2020
Location: Germany
Posts: 370
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
And just outputs the numbers, would be great, so I could simply use it with backticks to set the variables.
EctoOne is offline  
Old 07 January 2022, 21:36   #4
Ami
Registered User
 
Ami's Avatar
 
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
Ami is offline  
Old 07 January 2022, 22:45   #5
EctoOne
Registered User
 
EctoOne's Avatar
 
Join Date: Jun 2020
Location: Germany
Posts: 370
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#?
EctoOne is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:56.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.06920 seconds with 15 queries