*SOLVED* Changing a string of letters into something more readable Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
daniel
Posts: 17
Joined: 23 May 2016, 22:41

*SOLVED* Changing a string of letters into something more readable

26 Apr 2017, 15:29

Hello, AHK users, I have been using AHK for a while but only hotkeys and hotstrings and I am wondering how (which commands I would use) I would go about doing the following:

I have a string: r1bq1rk1/1RB2RK1

And I want to turn that into this: black rook, one square, black bishop, black queen, one square, black rook, black king, one square, next rank, one square, white rook, black bishop, two squares, white rook, white king, one square

First, is this possible with AHK? And which command will I need to use? Thank you very much.

PS If you think this is the wrong approach and that doing it with some other program is better please let me know.
Last edited by daniel on 26 Apr 2017, 16:33, edited 1 time in total.
User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: Changing a string of letters into something more readable  Topic is solved

26 Apr 2017, 16:11

This is one way.

Code: Select all

Array := ComObjCreate("Scripting.Dictionary")
Array.item("1") := "one square"
Array.item("2") := "two squares"
Array.item("/") := "next rank"
Array.item("r") := "white rook"
Array.item("b") := "white bishop"
Array.item("k") := "white king"
Array.item("q") := "white queen"
Array.item("R") := "black rook"
Array.item("B") := "black bishop"
Array.item("K") := "black king"
Array.item("Q") := "black queen"

String := "r1bq1rk1/1RB2RK1"

Loop, Parse, String
	Output .= Array.item(A_LoopField) ", "

Output := Trim(Output, " ,")

MsgBox % Output
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
daniel
Posts: 17
Joined: 23 May 2016, 22:41

Re: *SOLVED* Changing a string of letters into something more readable

26 Apr 2017, 16:40

Thank you, FanaticGuru!!

You are the man. Checking out your other stuff; dictionary's awesome.

Have a great day.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750, septrinus, songdg and 266 guests