Frustration galore

116 views
Skip to first unread message

Bob Jansen

unread,
Sep 11, 2020, 7:14:44 AM9/11/20
to TiddlyWiki
I am hoping that someone can shine some light on my issue as I have been working at it for some hours now to no success.

The task is to create a tiddler storing in a field a string, for example, ArtworkImages/BJ007.jpg, where the number is an incremental number and the text comes from various tiddlers, eg. $:/TLS/imagefoldername,  so it can be altered as required..

My code is as follows
<code>
\define artworkurl() <<foldername>><<idcode>><<incremental>><<imagecode>>

\define uniqueid()<<idcode>><<incremental>>

<$set name=foldername value={{$:/TLS/imagefoldername}} >
<$set name=imagecode value={{$:/TLS/imagetypecode}} >
<$set name=newid value= <<uniqueid>> >
<$set name=theurl value=<<artworkurl>> >
<$set name=idcode value={{$:/TLS/idcode}} >
<$set name=incremental value={{$:/TLS/incremental}} >

''Artwork unique ID: <<newid>>''

-----

idcode <<idcode>>

incremental <<incremental>>

foldername <<foldername>>

imagecode <<imagecode>>

newid <<newid>>

theurl <<theurl>>

-----

Artwork title: <$edit-text tiddler="$:/TLS/new-title" tag="input" default=""/>

Type: <$edit-text tiddler="$:/TLS/artwork-type" tag="input" default=""/>

Medium: <$edit-text tiddler="$:/TLS/medium" tag="input" default=""/>

Size: <$edit-text tiddler="$:/TLS/size" tag="input" default=""/>

Year created: <$edit-text tiddler="$:/TLS/year-created" tag="input" default=""/>

Number in edition: <$edit-text tiddler="$:/TLS/number-in-edition" tag="input" default=""/>

Submitted to exhibition: <$edit-text tiddler="$:/TLS/artwork-submitted-to-exhibition" tag="input" default=""/>

---

Purchased by: <$edit-text tiddler="$:/TLS/purchased-by" tag="input" default=""/>

Date purchased: <$edit-text tiddler="$:/TLS/date-purchased" tag="input" default=""/>

Price: <$edit-text tiddler="$:/TLS/price" tag="input" default=""/>

Status: <$edit-text tiddler="$:/TLS/status" tag="input" default=""/>

<$button>
<$action-createtiddler $basetitle="$:/TLS/new-id" $overwrite="yes" />
<$action-setfield $tiddler="$:/TLS/new-id" text=<<uniqueid>> />

<$action-createtiddler $basetitle="$:/TLS/artworkurl" $overwrite="yes" />
<$action-setfield $tiddler="$:/TLS/artworkurl" text=<<artworkurl>> />

<$action-setfield $tiddler="$:/TLS/incremental" text={{{ [{$:/TLS/incremental}add[1]] }}}/>
<$action-createtiddler 
     $basetitle={{$:/TLS/new-title}} 
     $template="Artwork Template" 
     tags="Artworks" 
     $overwrite="yes" 
     artwork_id={{$:/TLS/new-id}}
     artwork_url={{$:/TLS/artworkurl}} 
     artwork_numberinedition={{$:/TLS/number-in-edition}} 
     artwork_price={{$:/TLS/price}} 
     artwork_status={{$:/TLS/status}} 
     artwork_yearofcreation={{$:/TLS/year-created}} 
     purchased_by={{$:/TLS/purchased-by}} 
     artwork_medium={{$:/TLS/medium}} 
     artwork_size={{$:/TLS/size}} 
     artwork_price={{$:/TLS/price}} 
     artwork_status={{$:/TLS/status}} 
     date_purchased={{$:/TLS/date-purchased}}
     artwork_type={{$:/TLS/artwork-type}}
     artwork_submitted_to_exhibition={{$:/TLS/artwork-submitted-to-exhibition}}
/>
<$action-deletetiddler $tiddler="$:/TLS/new-title" />
<$action-deletetiddler $tiddler="$:/TLS/artworkurl" />
<$action-deletetiddler $tiddler="$:/TLS/new-id" />
<$action-deletetiddler $tiddler="$:/TLS/medium" />
<$action-deletetiddler $tiddler="$:/TLS/size" />
<$action-deletetiddler $tiddler="$:/TLS/year-created" />
<$action-deletetiddler $tiddler="$:/TLS/number-in-edition" />
<$action-deletetiddler $tiddler="$:/TLS/purchased-by" />
<$action-deletetiddler $tiddler="$:/TLS/date-purchased" />
<$action-deletetiddler $tiddler="$:/TLS/price" />
<$action-deletetiddler $tiddler="$:/TLS/status" />
<$action-deletetiddler $tiddler="$:/TLS/artwork-type" />
<$action-deletetiddler $tiddler="$:/TLS/artwork-submitted-to-exhibition" />
Add new artwork
</$button>

</code>

The problem is passing the values of  artwork_url and artwork_id into the new tiddler. The values stored are: artwork_id is <<idcode>><<incremental>> and artwork_url is <<foldername>><<idcode>><<incremental>><<imagecode>> instead of their values.

However, displaying the values of the variables  for debugging purposes gives:

idcode YB

incremental 20

foldername ArtworkImages/

imagecode .jpg

newid YB20

theurl ArtworkImages/YB20.jpg

These values are as they should be but they are not carried across into the action-createtiddler widget. 

I have tried passing the values through the local variables using for example, artwork_url=<<theurl>> or through a macro call artwork_url=<<artworkurl>> instead of  trying to get the value from the temporary tiddler artwork_url={{$:/TLS/artworkurl}} but nothing works.

What am I doing wrong?

bobj

Eric Shulman

unread,
Sep 11, 2020, 8:56:33 AM9/11/20
to TiddlyWiki
On Friday, September 11, 2020 at 4:14:44 AM UTC-7, Bob Jansen wrote:
The task is to create a tiddler storing in a field a string, for example, ArtworkImages/BJ007.jpg, where the number is an incremental number and the text comes from various tiddlers, eg. $:/TLS/imagefoldername,  so it can be altered as required..
The problem is passing the values of artwork_url and artwork_id into the new tiddler.
The values stored are: artwork_id is <<idcode>><<incremental>> and artwork_url is <<foldername>><<idcode>><<incremental>><<imagecode>> instead of their values.
However, displaying the values of the variables  for debugging purposes gives: ...

These values are as they should be but they are not carried across into the action-createtiddler widget. 

 
Macros do ONLY two kinds of processing:
1) Replace any instances of $arg$ passed in
2) Replace any instances of $(variable)$ that are defined *outside* the macro

Everything else contained inside a macro is returned exactly as defined within the macro.  It is up to the "calling context" to process the returned macro content.

When you write:
\define artworkurl() <<foldername>><<idcode>><<incremental>><<imagecode>>
\define uniqueid() <<idcode>><<incremental>>
The results are to simply return the macro's contents as shown.  The variables references inside the macros are not automatically converted to their values.

If you then *display* the results of the macro, the "<<variablename>>" syntax is automatically "wikified" to render the value stored in the variable.
However, when you use the results of the macro as a *parameter* in a $widget, the macro results are passed to the $widget "as-is" without further processing.

The easiest way to make your code work (assuming no other problems) is to change these two macros, like this:
\define artworkurl() $(foldername)$$(idcode)$$(incremental)$$(imagecode)$
\define uniqueid() $(idcode)$$(incremental)$
By doing this, the content returned from those macros WILL be the *values* of the variables, not the references to the variables.

-e

Dr Bob Jansen

unread,
Sep 11, 2020, 10:06:53 AM9/11/20
to tiddl...@googlegroups.com
Thanks Eric, will give this a try. In an earlier version, I did use the $(..)$ format and then for a reason I can't explain, replaced it by the <<..>> format after reading various manual pages.

BobJ

---------------
Dr Bob Jansen
The Cultural Conversations project 
Turtle Lane Studios Pty Ltd trading as the Australian Centre for Oral History
122 Cameron St, Rockdale NSW 2216, Australia 
Ph (Korea): +82 10-4494-0328 
Ph (Australia) +61 414 297 448 
Resume: http://au.linkedin.com/in/bobjan 
Skype: bobjtls 
KakaoTalk: bobjtls 
http://www.cultconv.com 

 In line with the Australian anti-spam legislation, if you wish to receive no further email from me, please send me an email with the subject "No Spam"
--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/uWum4aFZPmc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/23da8137-8fd3-4df6-bcd6-38040bee6544o%40googlegroups.com.

Bob Jansen

unread,
Sep 11, 2020, 8:46:26 PM9/11/20
to tiddl...@googlegroups.com
Spot on Eric, thanks

Bobj

Dr. Bob Jansen
122 Cameron St, Rockdale NSW 2216, Australia
Skype: bobjtls


On 11 Sep 2020, at 22:56, Eric Shulman <elsd...@gmail.com> wrote:

--
Reply all
Reply to author
Forward
0 new messages