Adding files to AmiDock from Hollywood

Discuss any general programming issues here
Post Reply
gtmooya
Posts: 11
Joined: Sun Apr 15, 2012 4:09 pm
Contact:

Adding files to AmiDock from Hollywood

Post 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!
gtmooya
Posts: 11
Joined: Sun Apr 15, 2012 4:09 pm
Contact:

Re: Adding files to AmiDock from Hollywood

Post 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 ('').
gtmooya
Posts: 11
Joined: Sun Apr 15, 2012 4:09 pm
Contact:

Re: Adding files to AmiDock from Hollywood

Post 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
:-)
Post Reply