It looks like you're new here. If you want to get involved, click one of these buttons!
<<for _i=0; _i < $timetable.length; _i++>>\ <<if ($timetable[_i][0] eq $dayofweek+1)>>\ <<print "You have a lecture on ">> <<for _m=0; _m < $courselist.length; _m++>>\ <<if ($courselist[_m][0] eq $timetable[_i][2]>>\ <<print $courselist[_m][1]>>\ <<set _m = $courselist.length>>\ <<endif>>\ <</for>>\ <<endif>>\ <</for>>
<<for _i=0; _i < $timetable.length; _i++>>\ <<if ($timetable[_i][0] eq $dayofweek+1)>>\ <<print "You have a lecture on ">> <<getcoursename $timetable[_i][2]>> <<endif>>\ <</for>>\ Passage: Main Widget <<widget "getcoursename">>\ <<for _m=0; _m < $courselist.length; _m++>>\ <<if ($courselist[_m][0] eq $args[0])>>\ <<print $courselist[_m][1]>>\ <<set _m = $courselist.length>>\ <<endif>>\ <</for>>\ <</widget>>\
Comments
You should be doing one of two things here:
Other minor issues I noticed:
2. what is the use of a backtick expression? pointer related? when should I use it?
3. endif - Got it. I used it to backward compatible with my old tws. Come to think of it, I dont really see the point.
4. it is so confusing to remember which language has BREAK and which does not. okay, so sugarcube has BREAK, that is good. sugarcube does not have WHILE loop nor the DO loop, right?
Neither SugarCube's macro syntax nor JavaScript have pointers, so it's definitely not pointer related.
It's simply a way to pass the result of an expression as a discrete argument to a macro, which—outside of a few special cases—is problematic because the macro argument parser doesn't treat arguments as expressions by default and because it separates arguments with whitespace.
Both of the options I outlined—the use of a temporary variable or a backtick expression—are to allow you to pass the result of the property access on $timetable as a discrete argument to the widget.
Not as macros, no. That said, SugarCube's <<for>> macro is multipurpose. You may invoke it with no expressions, a conditional expression only, or with a 3-part set (init, conditional, and post expressions). For example:
Mmmm. Okay. I do not recall something like back-tick expression in other programming languages. Is it Twine and/or Sugarcube only? No wait, an alien is popping up at the back of my mind. UNIX shell scripting?
Programming languages are so different with each other and sometimes it comes down to habit. I can manage myself. It is just I feel solid with a clarification from an expert.
Many thanks, TheMadExile. You are always the greatest help.