thanks for all the kind words and encouragement, everyone.
I will eventually consolidate and clean up all these tutorials into a single pdf help file.
I don't have as much time as I originally intended to write tutorials today, however, I did have a chance to share the alpha with a few people in chat and get initial impressions on what was most confusing, and what things needed special emphasis. Today's tutorial will be extremely basic. Basically a "hello world" program, and I will try to release at least one tutorial a day. Please feel free to ask questions, especially about "why isn't this working", and I will do my best to answer them throughout the day, and perhaps integrate any remaining questions in the next days tutorial.
keep in mind this plugin is in the alpha stage. Though I will follow basic steps to allow backward compatibility with previous versions, s will be updated on a sometimes daily basis, and advancing development will take priority over maintaining compatibility with caps created with alpha versions. Please do not begin any major projects that require this plugin until a non alpha/beta release.
<img src="http://dl.getdropbox.com/u/1013446/s/s.png">
first. download s:
click here to start download
extract the rar into your construct folder.
- Start a new project, and add one text object, and the s object.
- Add an At Start of Layout condition.
- With s, add an Add Array action
<img src="http://dl.getdropbox.com/u/1013446/s/helloworld.PNG">
- For the name of the array choose "words".
- Skip over within which super for now (leave it as {""}
- For the type choose String
- For the default, choose "default!!!" or anything else you're happy with
- The last option is only relevant when creating super arrays. we will come back to this in a later lesson.
You have now created an empty string container named "words" with a default value of "default!!!" (or whatever you chose as your default)
- Make a Set Text Event with your text object, and double click the s object to get a list of expressions. choose Get String
- Set Text to s.s({"words"})
do not omit the curly brackets {}, this is the number one cause of crashes amongst both myself and the test group earlier today. s.s({"words"}), not s.s("words").
<img src="http://dl.getdropbox.com/u/1013446/s/hello.PNG">
- Run your cap
if all went well your text should be set to the default value you chose, since your string has not been set to anything yet.
now let's take a look at the expression first we have s.s
every expression in s is abbreviated to as few letters as possible
to retrieve a value of each of the types the expressions are:
- s for a string value
- n for a numeric value
- o for an object variable's type
- ot for an objecttype variable
fairly straightforward to remember, and you can always double click the object if you forget.
inside the Get String expression you had {"words"}
in the last lesson we saw several examples of addresses.
this is a simple address, and fairly straightforward.
we will reexplore the syntax of addresses in greater detail in later lessons
for now, lets change our cap a little and make it a true hello world example.
between the action to create the string array, and before you set the text
- add an action with s to Add/Overwrite String in Array
- for the String to Add, choose a string. Try "hello world!"
- for Within which Array choose {"words"}. and don't forget the curly brackets!
- for How To Add Choose Insert
- Add/Overwrite where can be left as "end"
Now run cap again.
you should now see that ever so satisfying "hello world!" message.
This means your string container is not empty anymore.
it contains a single string value. Remember though that all containers can hold more than one value if necessary.
return to your cap, and copy/paste the Add/Overwrite String in Array action so you have 2 of them in a row
in the second one however, change the message to "Goodbye World!"
you now have two values in your "words" array
if you run your cap again, it should be no different than the first time.
you will get the value stored at 0 in your array
when you do not specify an index in your address ( {"words"} ):
0 is assumed
you could achieve the same result by changing it to {"words",0}
if you would like to access your goodbye message
set the text to {"words",1}.
try this and run the cap again.
try changing it to {"words",5} and running the cap again
unless you added extra strings yourself, you should get the default value.
any time you try to access an array location that is higher than the size of the array, you will get the default value.
I will introduce briefly some related concepts before closing today's lesson.
The first is the difference between overwrite, and insert.
overwrite does just that, it overwrites the current value at the index specified
insert adds the specified value, and if there is another value already at that index, the old value is pushed forward
so if you had two string values in {"words"}:
and you overwrote index 1 in ({"words"}) with the string "middle"
you would still have two string values, but the second would be overwritten with the new value:
and you inserted at index 1 ({"words"}) with "middle"
you would now have:
0
"beginning"
1
"middle"
2
"ending"
if you would like to try these in your cap, change the last value in the Add/Overwrite String in Array action from "end" to the numerical index you'd like
when attempting overwriting or inserting at a location higher than the highest index of the array, the array will increase in size, and any intermediate spaces will be filled with the default value, so if your default string was "nothing to see here" and you started with the array:
and you inserted the value "way up there" at index 7 in {"words"}, you would end up with
0
"beginning"
1
"ending"
2
"nothing to see here"
3
"nothing to see here"
4
"nothing to see here"
5
"nothing to see here"
6
"nothing to see here"
7
"way up there"
The last item for today is the "end" string value for the index you saw in the Add/Overwrite String in Array action
open your cap, and double click one of those actions.
the last setting in this action is Add/Overwrite where
it is defaulted to "end". This is the only valid string to insert here. normally you put numerical index values here. "end" is a convenient way of specifying the end of an array without having to retrieve it's size. if you choose to insert at "end", the item will be inserted after the last value in the array, if you overwrite at "end" the item will overwrite the last value in the array.
please feel free to experiment, especially repeating some of this lesson with numbers instead of strings. if you experiment too much you're bound to crash the plugin. it is not unstable, but as you can see thus far, it has a very specific syntax. please ask any questions you have. and stay tuned. After we get through the basics, we will begin to explore some of the things you can do with s, and the new level of power and organization it brings to construct.