Page 1 of 1

Adding files to AmiDock from Hollywood

Posted: Tue Jul 21, 2015 8:59 pm
by gtmooya
I've got my script to add files to AmiDock by using the following code:

Code: Select all

SendRexxCommand("AMIDOCK", "ADDSUBDOCK 'Music'")
SendRexxCommand("AMIDOCK", "ADDOBJECT '\"" .. target$ .. "\"' 'NAME=\"" .. name$ .. "\"' 'DOCKNAME=Music'")
In this target$ is the file to be added and name$ is what it will be called in AmiDock. The problem comes when the target file name contains a quote mark, e.g. It's cold on Pluto. If I were to drag and drop the same file onto AmiDock from Workbench it is added fine, so AmiDock can clearly handle quote marks in names.

Anyone know would I need to add to my code to get files containing quote marks onto AmiDock?

Thanks!

Re: Adding files to AmiDock from Hollywood

Posted: Wed Jul 22, 2015 9:12 am
by gtmooya
Found this on the AmigaOS Wiki:
A string is any group of characters beginning and ending with a quote (') or double quote (") delimiter. The same delimiter must be used at both ends of the string. To include the delimiter character in the string, use a double-delimiter sequence ('' or ""). For example:

"Now is the time." An example of a normal string.
'Can''t you see?' An example of a string using a double-delimiter sequence.
http://wiki.amigaos.net/wiki/AmigaOS_Ma ... s_of_ARexx

Tested the script by making a copy of a file and renaming it, e.g. It's cold on Pluto > It''s cold on Pluto. This worked with the icon for first file being added to AmiDock.

Now just need to work out how to get my script to find a quote (') and add in a second quote before it ('').

Re: Adding files to AmiDock from Hollywood

Posted: Wed Jul 22, 2015 10:15 am
by gtmooya
Found a simple solution using ReplaceStr:

Code: Select all

Function p_AmiDock()
     targetmod$ = ReplaceStr(target$, "'", "''")
     namemod$ = ReplaceStr(name$, "'", "''")
     ExitOnError(FALSE)
         SendRexxCommand("AMIDOCK", "ADDSUBDOCK 'Music'")
         SendRexxCommand("AMIDOCK", "ADDOBJECT '\"" .. targetmod$ .. "\"' 'NAME=\"" .. namemod$ .. "\"' 'DOCKNAME=Music'")
     ExitOnError(TRUE)
EndFunction
:-)