Match does not appear to be working

I am having problems with various match conditions that do not appear to be working.

This is the code and for test purposes, $:TLS/selectedstate!!state-code is set to -

The second <%if is not picking up the match condition and thus not displaying the message text. The first <%if works perfectly.

I have been looking at this some for time now to no avail. What am I doing wrong?

<%if [{$:/TLS/State/EditMode!!editMode}match[true]] %>

Add the information for the new gun below and press the //Add this gun// button

State Code: <$select tiddler="$:/TLS/selectedstate"  field="state-code">
{{$:/TLS/Select/State}}
</$select>
OS for overseas, PRI for private


<%if [{$:/TLS/selectedstate!!state-code}match[-]] %>

Error - the selected state code can not be '-'

<%elseif [{$:/TLS/selectedstate!!state-code}!match[]] %>
 
The ID number for this new gun will be {{{ [{$:/TLS/incremental}addprefix[RAAHC]] }}}


City/Town: <$edit-text tiddler="$:/TLS/city" tag="input"/>

Location: <$edit-text tiddler="$:/TLS/location" tag="input"/>

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

Coordinates - Latitude: <$edit-text tiddler="$:/TLS/latitude" tag="input" overwrite="yes"/>
<br>
Format decimal, eg -33.1234

Coordinates - Longitude: <$edit-text tiddler="$:/TLS/longitude" tag="input" overwrite="yes"/>
<br>
Format decimal, eg 150.4567

Date of Manufacture: <$edit-text tiddler="$:/TLS/dateofmanufacture" tag="input"/>

Manufacturer: <$edit-text tiddler="$:/TLS/manufacturer" tag="input" overwrite="yes"/> 

Serial Number: <$edit-text tiddler="$:/TLS/serialnumber" tag="input" overwrite="yes"/>  

Weight of Projectile: <$edit-text tiddler="$:/TLS/weightofprojectile" tag="input" overwrite=“yes” />

Range: <$edit-text tiddler="$:/TLS/range" tag="input" overwrite="yes"/>

Calibre: <$edit-text tiddler="$:/TLS/calibre" tag="input" overwrite="yes"/>

Picture Link: <$edit-text tiddler="$:/TLS/pictureLink" tag="input" overwrite="yes"/> 
<br>
The link for the main picture of the gun. Of the form //WA-image-0030//



<$button>

<$let 
    selectedstatecode={{$:/TLS/selectedstate!!state-code}} 
    selectedstatename={{{ [{$:/TLS/StateData}jsonget<selectedstatecode>] }}}
    locationTag={{$:/TLS/location}}
    typeTag={{$:/TLS/type}}
    cityTag={{$:/TLS/city}}
>


      <$action-createtiddler 
        $basetitle={{{ [{$:/TLS/incremental}addprefix[RAAHC]] }}}
         caption={{{ [<selectedstatename>addsuffix[ : ]addsuffix<cityTag>addsuffix[ - ]addsuffix{$:/TLS/type}] }}}
         tags={{{ [[All Guns]] [[Needs History]] [<cityTag>] [<selectedstatename >] [<locationTag>] [<typeTag>] +[format:titlelist[]join[ ]] }}}
          ID={{{ [{$:/TLS/incremental}addprefix[RAAHC]] }}}
          CityTown={{$:/TLS/city}}
          Location={{$:/TLS/location}}
          State=<<selectedstatename>>
         GunType={{$:/TLS/type}}
          DateofManufacture={{$:/TLS/dateofmanufacture}}
          Manufacturer={{$:/TLS/manufacturer}}
          SerialNumber={{$:/TLS/serialnumber}}
          WeightofProjectile={{$:/TLS/weightofprojectile}}
          Range={{$:/TLS/range}}
          pictureLink={{$:/TLS/pictureLink}}
          Calibre={{$:/TLS/calibre}}
          Longitude={{$:/TLS/longitude}}
          Latitude={{$:/TLS/latitude}}
           $template="$:/TLS/CreateTemplateGun">
          <$action-navigate $to=<<createTiddler-title>>/>
</$action-createtiddler>

<$action-createtiddler 
        $basetitle={{{ [{$:/TLS/incremental}addprefix[RAAHC]addsuffix[_History]] }}}
         caption="History"
         tags={{{ [{$:/TLS/incremental}addprefix[RAAHC]] }}}
          parentGun={{{ [{$:/TLS/incremental}addprefix[RAAHC]] }}}
           $template="$:/TLS/CreateTemplateHistory">
</$action-createtiddler>

<$action-createtiddler 
        $basetitle={{{ [{$:/TLS/incremental}addprefix[RAAHC]addsuffix[_Images]] }}}
         caption="Images"
         tags={{{ [{$:/TLS/incremental}addprefix[RAAHC]] }}}
          parentGun={{{ [{$:/TLS/incremental}addprefix[RAAHC]] }}}
           $template="$:/TLS/CreateTemplateImages">
</$action-createtiddler>

<$action-createtiddler 
        $basetitle={{{ [{$:/TLS/incremental}addprefix[RAAHC]addsuffix[_Why]] }}}
         caption="Why"
         tags={{{ [{$:/TLS/incremental}addprefix[RAAHC]] }}}
          parentGun={{{ [{$:/TLS/incremental}addprefix[RAAHC]] }}}
           $template="$:/TLS/CreateTemplateWhy">
</$action-createtiddler>

<$action-setfield $tiddler="Map" $field="parentGun" $value={{{ [{$:/TLS/incremental}addprefix[RAAHC]] }}} />

<$action-setfield $tiddler="Technical" $field="parentGun" $value={{{ [{$:/TLS/incremental}addprefix[RAAHC]] }}} />



<$action-setfield $tiddler="$:/TLS/dateofmanufacture" text=""/>
<$action-setfield $tiddler="$:/TLS/city" text=""/>
<$action-setfield $tiddler="$:/TLS/location" text=""/>
<$action-setfield $tiddler="$:/TLS/manufacturer" text=""/>
<$action-setfield $tiddler="$:/TLS/serialnumber" text=""/>
<$action-setfield $tiddler="$:/TLS/weightofprojectile" text=""/>
<$action-setfield $tiddler="$:/TLS/range" text=""/>
<$action-setfield $tiddler="$:/TLS/caption" text=""/>
<$action-setfield $tiddler="$:/TLS/pictureLink" text=""/>
<$action-setfield $tiddler="$:/TLS/longitude" text=""/>
<$action-setfield $tiddler="$:/TLS/latitude" text=""/>
<$action-setfield $tiddler="$:/TLS/calibre" text=""/>
<$action-setfield $tiddler="$:/TLS/type" text=""/>
<$action-setfield $tiddler="$:/TLS/selectedstate" $field="state-code" $value=""/>
<$action-setfield $tiddler="$:/TLS/selectedstate" $field="state-name" $value=""/>


<$action-setfield $tiddler="$:/TLS/incremental" text={{{ [{$:/TLS/incremental}add[1]] }}}/>

</$let>

Add new gun
</$button>

<%endif%>


<%else%>
Sorry, this function is only available in edit mode
<%endif%>

Also, the button for the Add new gun is a rectangle rather than the normal rounded rectangle.

bobj

It took me a while to look through this wall of code and I had to add indentation to check that your <% if %>...<% elseif %> ... <%endif %> were all nested and closed properly. So my next thought would be to check the data. It looks as if the match[-] should work properly, but I can’t tell from just your code. I know you have one version of this wiki at https://cultconv.neocities.org/ArtilleryRegister/. Is that the one you’re working on? Is there some backdoor to allow users to switch off read-only mode to allow me to test this add functionality? (When I need this, I personally use an obscure keystroke to toggle between the edit and read-only modes. Since the users can’t save back to the server anyway, it seems secure enough to me.) I’d love to be able to test, but haven’t found a way yet.

One thing to check: are you sure that the hyphen character in the code snippet is the same one that gets selected for the field value?

3 Likes

Got it but don’t know why or how.

I deleted and re typed the <%if statement and deleted and re-entered the selection data and all now works ok

Must have been some unprintable character.

No idea what else could have caused this.

The button now renders properly as well.

Thanks anyway @Scott_Sauyet

Bobj

I think there is a risk here, I had a similar problem before and did not find exactly why. My solution was to delete, even replace the following <here>

<%if<here>%>

It seems to me that this is the only kind of undelimited use of a filter in tiddlywiki and if you place one in a function to variable it is delimited when used eg <<functionane>> by << >> but you also need to deal with first result only being default.

Perhaps this is worth raising an issue for, though it would help if we can present examples. It may just be a matter of strengthening the validation within the effective delimiters of <%if and %>