For a school project:
I am writing a simple program that displays extremely basic coding tutorials. I'm looking for suggestions on how to best set-up my files that will hold each individual tutorial.
Example: step through a 'Hello World' program.
In an upper window it will display the code 1 line at a time. While in a lower window I want to add my own comments explaining what each line of code (currently displayed) does. For larger tutorials there would also be a menu allowing you to click to jump to different areas of the program, to look at certain parts of code again. Or to just back up a few lines to go over previous code again.
What I'm looking for:
I want each tutorial file to contain all needed info for the program to interpret it: Is there a menu, whats on it, where does each link jump to, which info is code, which info is comments, which comments go with each line of code, & is there an easier way to jump around my tutorial without doing something like saving line numbers & re-reading the file each time, going to that line.
What I was thinking:
I was thinking I could just write the tutorial in a normal text file as-if I was writing the real program & include the needed comments after each line of code (on lines seperate from the code). Then when I load a tutorial i could just read the file & do something like regex..
Read & interpret the first few lines that tell me what the menu is like & what line #'s they jump to. Then read & display 'code' in the upper window until i hit a line that starts with //, then read lines into the bottom (comment) window until i hit a line that doesn't start with // (so now I know I'm at the next line of code). Then stop & wait for the user to click next, continue until i hit EOF. Then to add a new tutorial I just write another text file.
Problem: This would work, but it sounds sloppy.
It would force me to re-read the file everytime I wanted to jump around to a different position. And if I ever wanted to edit or expand a tutorial I would have to manualy recount & change all the line numbers for my menu. Just doesn't sound like a great way to accomplish what I want.
What do you think: So is there an easier way I could set up a tutorial file to hold the needed information. So I can associate each line of code with x lines of comments, set up information for a menu, & allow an easier way to track positions in the tutorial to allow jumping around to different areas of the tutorial?
I am writing a simple program that displays extremely basic coding tutorials. I'm looking for suggestions on how to best set-up my files that will hold each individual tutorial.
Example: step through a 'Hello World' program.
In an upper window it will display the code 1 line at a time. While in a lower window I want to add my own comments explaining what each line of code (currently displayed) does. For larger tutorials there would also be a menu allowing you to click to jump to different areas of the program, to look at certain parts of code again. Or to just back up a few lines to go over previous code again.
What I'm looking for:
I want each tutorial file to contain all needed info for the program to interpret it: Is there a menu, whats on it, where does each link jump to, which info is code, which info is comments, which comments go with each line of code, & is there an easier way to jump around my tutorial without doing something like saving line numbers & re-reading the file each time, going to that line.
What I was thinking:
I was thinking I could just write the tutorial in a normal text file as-if I was writing the real program & include the needed comments after each line of code (on lines seperate from the code). Then when I load a tutorial i could just read the file & do something like regex..
Read & interpret the first few lines that tell me what the menu is like & what line #'s they jump to. Then read & display 'code' in the upper window until i hit a line that starts with //, then read lines into the bottom (comment) window until i hit a line that doesn't start with // (so now I know I'm at the next line of code). Then stop & wait for the user to click next, continue until i hit EOF. Then to add a new tutorial I just write another text file.
Problem: This would work, but it sounds sloppy.
It would force me to re-read the file everytime I wanted to jump around to a different position. And if I ever wanted to edit or expand a tutorial I would have to manualy recount & change all the line numbers for my menu. Just doesn't sound like a great way to accomplish what I want.
What do you think: So is there an easier way I could set up a tutorial file to hold the needed information. So I can associate each line of code with x lines of comments, set up information for a menu, & allow an easier way to track positions in the tutorial to allow jumping around to different areas of the tutorial?