02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Trace

Before starting with visuals, we must first learn how to get the output in plain text. This is possible with the help of functions. Once we declare a function, we can call it any number of times within the same program and get the work done is short time. For now we'll just focus on a simple syntax for printing any text on the output panel by using the keyword 'trace'.

We must always be aware of the code's syntax before using it in the program. Now, we know that trace is used for typing the text but we must follow the correct syntax or the command won't work. The word trace must be followed with (), where single or double quotes are included within the parenthesis. The text that is to be printed must be between these quotes. Finally, end the line with semicolon (;). It is a must for every line to end with a semicolon if it is not continued further. We can write any number of trace commands within a program. The general syntax for trace is trace("02 Rocks!!!!");. The text inside can be a character or string.

This is the basic step for producing output and is used in almost every program. You must have "trace" down pat before going to the next video because it is also widely used in the visual programs: you don't want to commit mistakes while writing the syntax for trace (you'll make enough other errors, we all do – and we all use "trace" to find them!) There are few more things you should know about the trace syntax. You must be very specific about the data type that is declared and assigned when you're dealing with variables. This was discussed earlier as well. After watching this video, you must be able to get the desired text output at will. Practice this at least once before moving to the next video: can you output a single line joke?

Video Transcript

00:00As we start programming and we program more and more we're gonna find out that
00:06we're gonna have we're gonna need to figure out a way how could we output
00:10things to ourselves. How do we output things that aren't going to go to the
00:15user but they're just gonna go to ourselves so we could test things out.
00:18And most of our application at this phase is gonna be in the output mode.
00:22We're not gonna do things that are visual yet. And the way to output
00:28things is by calling a function which a function is basically a way to call to
00:36make commands inside of flash. So we're gonna call a command in flash that's
00:40called trace. So if we type now the word trace inside of the area of our code
00:44inside of the area dedicated for our public function made between main between
00:50our brackets. So we want to make sure that we don't go out of this internal
00:53bracket where our main function is. Now if I start typing in trace and I open a
01:01bracket around bracket I could send to the trace panel as we're publishing
01:08things information and the way I do that I wrap it into into quotes. It could be
01:14double quotes it could be regular quotes. So I'm gonna I'm gonna double quote
01:18right now one two and I'm gonna close my bracket and I'm gonna end this line
01:26with a semicolon. So now if I run it I'm not gonna see much but I could write
01:33inside of the inside of the between the the quotes double quotes doesn't really
01:41matter I could write something. So I could write any string I want on my
01:44keyboard so the testing is this working. But let's make it kind of more
01:53traditional the way every book that goes to teach flash or any program starts with
01:59which is hello world. So we don't want to be too fancy. So now if I try to I'm
02:06gonna save the file don't forget to save before before you publish. Now if I
02:11click on command enter again and publish the file you're gonna see that my output
02:16says hello world and that's all I had to do to create my first very very minimal
02:22application. Throughout the courses that we're gonna be working on we're gonna
02:27be reusing this trace function a lot of times. Now if the word function is kind of
02:33enigmatic at this point don't worry about we're gonna get into depth what
02:37functions are. But for now for this video what you need to understand is you
02:40need to type the words trace open a bracket close the bracket and inside of
02:47the inside of these round brackets we're gonna open a double quote or a quote and
02:52close it correlating once if we open a double one we're gonna close it with a
02:56double one if we open the one quote we're gonna close it with a one quote
03:00and we're just gonna write our text in between and whatever we write inside
03:04here will trace out whatever we want. So the same way we could we could trace
03:09another one so I'm gonna just type trace and this time I'm gonna put only one
03:13bracket and I'm gonna say hello again hello or let's make it even more cheesy
03:24I am Ben Fella which is my name uppercase Ben which I always forget to
03:35do uppercase for the last name and I'm gonna close it with a single quote as
03:38well cuz I open it with a single quote close a bracket and a semicolon and I'm
03:44gonna save one more time and publish my file to see if that worked and we could
03:49see that you have your low world and I am Ben Fella. Now the next thing I want
03:53you to do before you start the next video create your own trace just make
03:57sure that this creating a trace you could do on your own so just stop the
04:01video for a minute we're gonna make a little pause make a trace on your own
04:05and then let's continue on to the next video

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!