Recently, "Alex Tweedly" wrote: > One of the things that is a bit of a hurdle for a "traditional language > programmer" (like me) to overcome is the unusual syntax and verbosity of > Transcript. I'm trying to convince myself that this will feel more natural > if I just keep trying :-) > > Are there any "style" hints or suggestions to help with this ?
You may get many answers to this. For general reference, FourthWorld has a good scripting guide: http://www.fourthworld.com/embassy/articles/scriptstyle.html Otherwise, it's *usually* best to avoid assigning names to controls that include the control's type, are simple numbers, or reserved words. While these names are certainly possible, using descriptive names (ie field "myCoolData") will help you avoid scripting errors until you are more used to the language. For example, avoid naming a field "6" or "into". Controls must be referenced by their class and a name, number or id: put "hello" into field "my stuff" put "hello" into field 1 put "hello" into field id 1005 Control names and messages are usually referenced with double quotes to avoid confusion with variable names. put 20 into field "myStuff" send "myStuff" to button 9 put 20 into myStuff > 2. String concatenation > I had > put URL "file:" & fileName into myVar > of course, I meant > put URL ("file:" & fileName) into myVar > or similar. Generally, xtalk is a bit forgiving in syntax, but the above is one case where it's not (not sure why). When concatenating, it's usually best to employ parens to avoid possible ambiguity, similar to math expressions: put 2 * 4 + 5 into myVar is not the same as: put 2 * (4 + 5) into myVar > 3. Traditional programing style. > I forgot myself and wrote a traditional line of code > myVar = 1 > when I meant > put 1 into myVar > OK, my error; but I sure wish the compiler could warn me when I write an > expression and never use it (or something to catch my slips into > traditional languages) You should have seen an error come up when trying to apply the above within a script. In any event, it will be worth your while to get in the habit of using "put x into y" since this is the fundamental syntax of xtalk languages. However, you may find some solace in the similarity of declaring local variables in a script: on mouseUp local x=1,y=2,z=3 answer y end mouseUp Hope some of this helps. Keep at it. Regards, Scott Rossi Creative Director Tactile Media, Multimedia & Design ----- E: [EMAIL PROTECTED] W: http://www.tactilemedia.com _______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
