List Info

Thread: if then else




if then else
country flaguser name
United States
2007-10-14 08:45:12
Hi, I hope the group can help me out again.
I would like to use variables and condition them with if,
else, endif,
set, print macros. In other words all the wizz-bang stuff in
tweebox.

However I want the full control of my own Tiddlywiki so I
can have all
sort of other plugins, e.g BreadcrumbsPlugin,
SinglePageModePlugin,
and a host of others. Plus Tweebox seems to be missing
control of
setting variables, e.g. the <<option>> macro.
Not being able to input
the variables is a show stopper for my project.

Does someone have <<If>>, <<else>>,
<<endif>> <<set>>, and
<<print>>
macros which can be used in TW 2.x?

Or alternately, is the guy who developed Tweebox and Jonah
following
this group? If so would those macros be available so I can
take the
code and implement them into the latest TW version?

Thanks,
Joe


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "TiddlyWiki" group.
To post to this group, send email to TiddlyWikigooglegroups.com
To unsubscribe from this group, send email to
TiddlyWiki-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: if then else
country flaguser name
Germany
2007-10-14 08:58:32
> I would like to use variables and condition them with
if, else, endif,
> set, print macros. In other words all the wizz-bang
stuff in tweebox.

I'm not very familiar with Tweebox, so that might explain
why I don't 
fully understand what you need.
Generally speaking, conditional statements can be
implemented using 
JavaScript code - so either with evaluated parameters (see
[1]) or with 
inline scripting ([2]).

Could you give us a concise example of what you need to do?


-- F.


[1] http://tinyurl.com/yw59q8 
(http://groups.google.com/group/TiddlyWiki/browse_thr
ead/thre
ad/991885b303b11360)

[2] ht
tp://www.TiddlyTools.com/#InlineJavascriptPlugin

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "TiddlyWiki" group.
To post to this group, send email to TiddlyWikigooglegroups.com
To unsubscribe from this group, send email to
TiddlyWiki-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: if then else
country flaguser name
United States
2007-10-14 11:24:57
Hmmmm, I'll have to investigate the InlineJavaScriptPlugin.
I've heard
banter about it, true, but hadn't thought it applied to what
I need.

Okay, here's what I want to do: This is a simplified example
using the
Tweebox syntax:

You are standing at the edge of a cliff, there is nowhere to
run.
Trolls are chasing you.
[[Fight Trolls]]
<<if $haveMountainClimbingGear >>
Or you can climb down the cliff with the mountain climbing
gear you
had the foresight to bring with you.
[[Descend Cliff]]
<<endif>>

And of course, in some previous tiddler there would be a
macro
assigning true to $haveMountainClimbingGear if the
appropriate
conditions there are met.


On Oct 14, 3:58 pm, FND <Ace_No...gmx.net> wrote:
> > I would like to use variables and condition them
with if, else, endif,
> > set, print macros. In other words all the
wizz-bang stuff in tweebox.
>
> I'm not very familiar with Tweebox, so that might
explain why I don't
> fully understand what you need.
> Generally speaking, conditional statements can be
implemented using
> JavaScript code - so either with evaluated parameters
(see [1]) or with
> inline scripting ([2]).
>
> Could you give us a concise example of what you need to
do?
>
> -- F.
>
> [1]http://tinyurl.com/yw59q8
> (http://groups.google.com/group/TiddlyWiki/browse_thr
ead/thre
> ad/991885b303b11360)
>
> [2]ht
tp://www.TiddlyTools.com/#InlineJavascriptPlugin


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "TiddlyWiki" group.
To post to this group, send email to TiddlyWikigooglegroups.com
To unsubscribe from this group, send email to
TiddlyWiki-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: if then else
country flaguser name
United States
2007-10-14 11:47:23
> Hmmmm, I'll have to investigate the
InlineJavaScriptPlugin. I've heard
> banter about it, true, but hadn't thought it applied to
what I need.

Using
   ht
tp://www.TiddlyTools.com/#InlineJavascriptPlugin
your example could be written this way:
-----
You are standing at the edge of a cliff, there is nowhere to
run.
Trolls are chasing you.
[[Fight Trolls]]
{{hidden{
<script>if(haveMountainClimbingGear)place.style.displa
y="block";</
script>
Or you can climb down the cliff with the mountain climbing
gear you
had the foresight to bring with you.
[[Descend Cliff]]
}}}

where:
"hidden" is a CSS class, defined as:
   .hidden { display:none; }
and
   haveMountainClimbingGear is a javascript variable, which
is set in
some other tiddler by using this javascript code:
  
<script>haveMountainClimbingGear=true;</script>

HTH,
-e
Eric Shulman
TiddlyTools / ELS Design Studios


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "TiddlyWiki" group.
To post to this group, send email to TiddlyWikigooglegroups.com
To unsubscribe from this group, send email to
TiddlyWiki-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: if then else
country flaguser name
United States
2007-10-14 12:10:45
Thanks, I'll give it a try right now!!!

On Oct 14, 6:47 pm, Eric Shulman <elsdes...gmail.com> wrote:
> > Hmmmm, I'll have to investigate the
InlineJavaScriptPlugin. I've heard
> > banter about it, true, but hadn't thought it
applied to what I need.
>
> Using
>    ht
tp://www.TiddlyTools.com/#InlineJavascriptPlugin
> your example could be written this way:
> -----
> You are standing at the edge of a cliff, there is
nowhere to run.
> Trolls are chasing you.
> [[Fight Trolls]]
> {{hidden{
>
<script>if(haveMountainClimbingGear)place.style.displa
y="block";</
> script>
> Or you can climb down the cliff with the mountain
climbing gear you
> had the foresight to bring with you.
> [[Descend Cliff]]
>
> }}}
>
> where:
> "hidden" is a CSS class, defined as:
>    .hidden { display:none; }
> and
>    haveMountainClimbingGear is a javascript variable,
which is set in
> some other tiddler by using this javascript code:
>   
<script>haveMountainClimbingGear=true;</script>
>
> HTH,
> -e
> Eric Shulman
> TiddlyTools / ELS Design Studios


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "TiddlyWiki" group.
To post to this group, send email to TiddlyWikigooglegroups.com
To unsubscribe from this group, send email to
TiddlyWiki-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: if then else
user name
2007-10-14 17:29:30
Here's another way with HideWhenPlugin

You are standing at the edge of a cliff, there is nowhere to run.
Trolls are chasing you.
[[Fight Trolls]]
{{x{<<showWhen haveMountainClimbingGear>>
Or you can climb down the cliff with the mountain climbing gear you
had the foresight to bring with you.
[[Descend Cliff]]
}}}
<<endif>>;

But actually as I mentioned in another thread, there was a plugin that does exactly what you describe only I can't recall what it was called or who wrote it.

On 10/15/07, DenizenOfAsgard < american.werewolf.in.budapestgmail.com">american.werewolf.in.budapestgmail.com> wrote:

Thanks, I'll give it a try right now!!!

On Oct 14, 6:47 pm, Eric Shulman < elsdes...gmail.com">elsdes...gmail.com> wrote:
>; > Hmmmm, I'll have to investigate the InlineJavaScriptPlugin. I've heard
> > banter about it, true, but hadn't thought it applied to what I need.
&gt;
> Using
>  ; &nbsp;http://www.TiddlyTools.com/#InlineJavascriptPlugin
&gt; your example could be written this way:
> -----
> You are standing at the edge of a cliff, there is nowhere to run.
>; Trolls are chasing you.
> [[Fight Trolls]]
&gt; {{hidden{
> <script>if(haveMountainClimbingGear)place.style.display=&quot;block&quot;;</
&gt; script>
> Or you can climb down the cliff with the mountain climbing gear you
> had the foresight to bring with you.
> [[Descend Cliff]]
&gt;
> }}}
>
&gt; where:
>; "hidden" is a CSS class, defined as:
>&nbsp; &nbsp; .hidden { display:none; }
> and
>  ; &nbsp;haveMountainClimbingGear is a javascript variable, which is set in
> some other tiddler by using this javascript code:
>  ; &nbsp;<script>haveMountainClimbingGear=true;</script>
>
> HTH,
>; -e
> Eric Shulman
&gt; TiddlyTools / ELS Design Studios







--
simon.bairdgmail.com">simon.bairdgmail.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TiddlyWiki"; group.
To post to this group, send email to TiddlyWikigooglegroups.com
To unsubscribe from this group, send email to TiddlyWiki-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: if then else
user name
2007-10-14 17:32:45
Ahah. TiddlyVault to the rescue! (Cheers Dave).

http://rgplugins.tiddlyspot.com/#%5B%5BhideIfshowIf%20plugin%5D%5D

On 10/15/07, Simon Baird < simon.bairdgmail.com">simon.bairdgmail.com> wrote:
Here';s another way with HideWhenPlugin

You are standing at the edge of a cliff, there is nowhere to run.
Trolls are chasing you.
[[Fight Trolls]]
{{x{<<;showWhen haveMountainClimbingGear>>
Or you can climb down the cliff with the mountain climbing gear you
had the foresight to bring with you.
[[Descend Cliff]]
}}}
<<endif>&gt;

But actually as I mentioned in another thread, there was a plugin that does exactly what you describe only I can't recall what it was called or who wrote it.


On 10/15/07, DenizenOfAsgard < american.werewolf.in.budapestgmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> american.werewolf.in.budapestgmail.com> wrote:

Thanks, I'll give it a try right now!!!

On Oct 14, 6:47 pm, Eric Shulman < elsdes...gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">elsdes...gmail.com> wrote:
>; > Hmmmm, I'll have to investigate the InlineJavaScriptPlugin. I've heard
&gt; > banter about it, true, but hadn't thought it applied to what I need.
&gt;
> Using
>  ; &nbsp;http://www.TiddlyTools.com/#InlineJavascriptPlugin
> your example could be written this way:
> -----
> You are standing at the edge of a cliff, there is nowhere to run.
>; Trolls are chasing you.
> [[Fight Trolls]]
&gt; {{hidden{
> <script>if(haveMountainClimbingGear)place.style.display=&quot;block&quot;;</
&gt; script>
> Or you can climb down the cliff with the mountain climbing gear you
> had the foresight to bring with you.
> [[Descend Cliff]]
&gt;
> }}}
>
&gt; where:
>; "hidden" is a CSS class, defined as:
>&nbsp; &nbsp; .hidden { display:none; }
> and
&gt; &nbsp; &nbsp;haveMountainClimbingGear is a javascript variable, which is set in
> some other tiddler by using this javascript code:
>  ; &nbsp;<script>haveMountainClimbingGear=true;</script>
>
> HTH,
>; -e
> Eric Shulman
&gt; TiddlyTools / ELS Design Studios







--
simon.bairdgmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">simon.bairdgmail.com



--
simon.bairdgmail.com">simon.bairdgmail.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TiddlyWiki"; group.
To post to this group, send email to TiddlyWikigooglegroups.com
To unsubscribe from this group, send email to TiddlyWiki-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: if then else
country flaguser name
United States
2007-10-15 00:48:48
Simon, in your example, how is

 haveMountainClimbingGear

defined?

also the " <<endif>> " was just
included by mistake, right? (I didn't
see a preceeding "if" anywhere)



Eric, Is there an advantage to using inline javascript for
this kind
of thing, or is it just preference?


Thanks to both of you in advance,
 DP


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "TiddlyWiki" group.
To post to this group, send email to TiddlyWikigooglegroups.com
To unsubscribe from this group, send email to
TiddlyWiki-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: if then else
user name
2007-10-15 08:16:36
On 10/15/07, Dave Parker < cedardoctelus.net">cedardoctelus.net> wrote:

Simon, in your example, how is

haveMountainClimbingGear

defined?

No idea really. But something more practical might look like this:

<;<showWhen store.fetchTiddler(&quot;Inventory").tags.contains("MountainClimbingGear";) >>

(use tags in a particular tiddler to indicate the items carried).


Or this:
<<showWhen hasInventoryItem(&quot;MountainClimingGear&quot;) >>

(Make up your own function. Requires some coding)



also the " <<endif>> " was just included by mistake, right? (I didn't
see a preceeding "if&quot; anywhere)

Oh yeah sorry. Pasting error.

But note that the corresponding example using the hideIfShowIf plugin from here:
http://rgplugins.tiddlyspot.com/#%5B%5BhideIfshowIf%20plugin%5D%5D
look like this:

<;<showIf hasInventoryItem(&quot;MountainClimingGear&quot;)>&gt;
[[Descend Cliff]]
<<endIf>>

Which is more readable.

However (for those still with me), I think some kind of a preprocessing language might be of use for many TiddlyWiki applications, eg:

C style:

#if hasInventoryItem(&quot;MountainClimingGear&quot;)
[[Descend Cliff]]
#endif


jsp/asp style maybe:

&lt;% if (hasInventoryItem(&quot;MountainClimingGear")) { %>
[[Descend Cliff]]
&lt;% } %>

this one is good because it's using javascript (not a made up syntax).

<% if (hasInventoryItem(&quot;MountainClimingGear")) { %>
You have ropes. You may [[Descend Cliff]]
<% } else { %>
In desperation you can [[Jump]].
<% } %>


Eric, do you think InlineJavascript could be made to work in this way, eg?

<;script>if (hasInventoryItem(&quot;MountainClimingGear")) </script>
[[Descend Cliff]]
<script&gt; } </script>



Simon.


--
simon.bairdgmail.com">simon.bairdgmail.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TiddlyWiki"; group.
To post to this group, send email to TiddlyWikigooglegroups.com
To unsubscribe from this group, send email to TiddlyWiki-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: if then else
country flaguser name
United States
2007-10-15 15:21:56
The only way I know how to define a variable is going into
the TW file
and adding a line under
config.options = {
What's a better way to define a variable, because this
doesn't seem to
be working.

Is this a definition?
<<showWhen
store.fetchTiddler("Inventory").tags.contains(&quo
t;MountainClimbingGear")
If so, where does it go? StyleSheets or some place like
that?

Your 3 examples leave me a bit confused. I can enter either
style of
syntax right into the code?

thanks, Joe

On Oct 15, 3:16 pm, "Simon Baird"
<simon.ba...gmail.com> wrote:
> On 10/15/07, Dave Parker <cedar...telus.net> wrote:
>
>
>
> > Simon, in your example, how is
>
> > haveMountainClimbingGear
>
> defined?
>
> No idea really. But something more practical might look
like this:
>
> <<showWhen
store.fetchTiddler("Inventory").tags.contains(&quo
t;MountainClimbingGear")
>
>
>
> (use tags in a particular tiddler to indicate the items
carried).
>
> Or this:
> <<showWhen
hasInventoryItem("MountainClimingGear") >>
>
> (Make up your own function. Requires some coding)
>
> also the " <<endif>> " was just
included by mistake, right? (I didn't
>
> > see a preceeding "if" anywhere)
>
> Oh yeah sorry. Pasting error.
>
> But note that the corresponding example using the
hideIfShowIf plugin from
> here:http://rgplugins.tiddlyspot.com/#%5B%5BhideIfs
howIf%20plugin%5D%5D
> look like this:
>
> <<showIf
hasInventoryItem("MountainClimingGear")>>
> [[Descend Cliff]]
> <<endIf>>
>
> Which is more readable.
>
> However (for those still with me), I think some kind of
a preprocessing
> language might be of use for many TiddlyWiki
applications, eg:
>
> C style:
>
> #if hasInventoryItem("MountainClimingGear")
> [[Descend Cliff]]
> #endif
>
> jsp/asp style maybe:
>
> <% if
(hasInventoryItem("MountainClimingGear")) { %>
> [[Descend Cliff]]
> <% } %>
>
> this one is good because it's using javascript (not a
made up syntax).
>
> <% if
(hasInventoryItem("MountainClimingGear")) { %>
> You have ropes. You may [[Descend Cliff]]
> <% } else { %>
> In desperation you can [[Jump]].
> <% } %>
>
> Eric, do you think InlineJavascript could be made to
work in this way, eg?
>
> <script>if
(hasInventoryItem("MountainClimingGear"))
</script>
> [[Descend Cliff]]
> <script> } </script>
>
> Simon.
>
> --
> simon.ba...gmail.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "TiddlyWiki" group.
To post to this group, send email to TiddlyWikigooglegroups.com
To unsubscribe from this group, send email to
TiddlyWiki-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: if then else
country flaguser name
Germany
2007-10-15 15:51:29
> The only way I know how to define a variable is going
into the TW file
> and adding a line under config.options = {

Hacking the source is generally a bad idea.
Instead, you could create a new tiddler to initialize your
variables: 
Tag it with "systemConfig", then add something
like this:
     foo = {};
     foo.bar = "baz";
* "foo" would be your global category (e.g.
"textAdventure")
* "bar" would be the name of your variable (e.g.
"inventory")
* "baz" would be the desired value (e.g.
"MountainClimbingGear")

> Is this a definition?
> <<showWhen
>
store.fetchTiddler("Inventory").tags.contains(&quo
t;MountainClimbingGear")
> If so, where does it go? StyleSheets or some place like
that?

No, that checks whether the tiddler "Inventory"
contains a tag 
"MountainClimbingGear".
Using InlineJavaScriptPlugin, you could update your variable
in any 
tiddler by inserting something like
     <script>foo.bar =
"zab";</script>
However, making this conditional (so it's only executed,
say, when the 
user clicks a button) will require some thinking - and most
likely at 
least basic coding skills.

> Your 3 examples leave me a bit confused. I can enter
either style of
> syntax right into the code?

I think Simon was just thinking aloud there, suggesting a
framework for 
a potential plugin...


-- F.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "TiddlyWiki" group.
To post to this group, send email to TiddlyWikigooglegroups.com
To unsubscribe from this group, send email to
TiddlyWiki-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-11]

about | contact  Other archives ( Real Estate discussion Medical topics )