On Sunday, June 7, 2020 at 5:48:31 AM UTC-7, Jake wrote:
>
> but what if I want a "universal" macro with usage like:
>
<<gofolder "text to show" "Folder" "MySubfolder/myfile.txt">>
>

On Sunday, June 7, 2020 at 9:25:21 AM UTC-7, Eric Shulman wrote:

> ...you could just write:
> \define gofolder(text,file) [ext[$text$|file:///$file$]]
> which you would call like this:
> <<gofolder "text to show" "Folder/MySubfolder/myfile.txt">>
> See.  Nice and simple!
>

Addendum:

There *is* a drawback to the "universal" macro, in that every usage would 
then contain a literal instance of the folder name.
If you wanted to move that folder later on, you would have to change each 
place you called the macro!

With the "folder name stored in a separate tiddler" method, you only have 
to change the folder value once, in the separate tiddler,
and all instances of the macro usage would stay the same, but use the newly 
changed folder value.

To keep "the best of both worlds", you could do something like this:
\define gofolder(text,foldertid,file) <$vars folder={{$foldertid$}}><<link2file 
"$text$" "$file$">></$vars>
\define link2file(text,file) [ext[$text$|file:///$(folder)$/$file$]]
with tiddlers [[MyDocs Path]], [[MyImages Path]], [[MyData Path]], 
[[Downloads Path]] defining path to the folders.

and then call it like this:
<<gofolder "text to show" "MyDocs Path" "agreement/doc1.doc">>
<<gofolder "text to show" "MyImages Path" "Scenery/lake.img">>
<<gofolder "text to show" "MyData Path" "Data/something.dat">>
<<gofolder "text to show" "Downloads Path" "Downloads/somefile.ext">>

enjoy,
-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/a3ae2cff-d049-4707-8890-0ff50a11eb63o%40googlegroups.com.

Reply via email to