 So you've seen a few of the advanced features in Rapture. I want to show you one more called the Loader. And I think I should apologize in advance because I really shouldn't show you this at 3.30 the end of a very long day when you've been slogging with GDB and everything else all day long because you guys are probably getting a little tired and this is really going to kill you. So hang on, you're going to love it. Alright. There's a thing in Rapture called the Loader and it's a fairly simple concept. Suppose you have a couple of test cases that you want people to be able to load up. So load up test case A with these values, load up test case B with these other values. That's a good thing to have for your tool because when somebody goes to run your tool they like to have a couple of examples that they can run that work out of the box again so they can try things out without really knowing what they're supposed to type in. So there's this thing in Rapture called the Loader that does that and the Loader looks like a combo box but usually at the top of your interface and the choices on the combo box are example cases. Let's call them that. So when you put a Loader on your interface it'll look kind of like that combo box that I'm showing you right up here. That's a Loader. Right there, that thing. So the interesting thing about the Loader is that you load these different example cases including we'll see how to upload and things like that. The example cases that you load you can set various values within the interface. So when I load a case called change both, suppose I drop down the menu I say change both. It will load an example case that maybe changes the first input and the second input. I can have it set the first input to first and the second input to second. Change both does that. In other words the Loader can change other controls in Rapture. That's interesting. It's loading an example case and it's setting other values in the interface. You notice it left the mass alone. The mass was 10 grams and left the mass alone. So all it did was change the first two controls. I might also choose the case that says change first. In this case the example case change first only changes the first input and changes it to the value hello and it leaves everything else alone. And there's also a case for change second where if I choose that next it will change the second input but it'll leave the others alone. So a couple of things. The Loader loads up values for an example case. It fills those values in on all the various controls in your program. It can change some and not others because in some cases when you load up an example case you just want a few things to change but you don't want other things. You want to leave other things that they're default values or whatever the user selected. So the Loader is a little tricky that way. It changes controls and not always all of them depending on what you do. There's also a new case. A lot of times with the Loader it's a good idea to give the user a way to reset back to the beginning. So if they chose the new case then maybe you'd reset everything to blank or enter a new value or something like that. So Loader usually comes along with a new case that lets you start fresh. All right. Now the Loader is one of the things that's not yet built into the builder. So it'd be really great. This lecture would already be over by now if all you had to do was drag it over from the builder and drop it into your tool. And unfortunately it's not like that. When you add the Loader into your tool the only way to do it is by adding into the tool definition the tool.xml. So I'm going to show you how to do it and it always takes like a couple of passes for people to understand how it's working. So the first thing inside my tool.xml I can add a little stanza like this. I add Loader and then about with a label and a description and then some other stuff and then slash Loader. So as long as you have that much Rapture recognizes that there's a Loader in your program. The label of the Loader will be in the about label section. It says example here. So you notice over on the left hand side it says example colon. So you can set the label that's next to the Loader using that label parameter. You can set the description too. That's the tool tip that pops up when you touch the Loader. Now the question is what do you want to have in the Loader? What do you want the Loader to show? One thing you can do is have a new case. You see how there's the new thing right there? I think I have a thing for that and examples I guess. I have both. So let's start with examples. In the example, I say example star dot XML and what that does is it finds all the examples that it can and loads them on that menu. So if I say example star dot XML it'll look for a bunch of XML files and for each one it finds it will treat that as an example case for the Loader. So where do those XML files come from? Wherever your tool dot XML is sitting you can make a directory called examples. Rapture looks for that. It has to be called examples, E-X-A-M-P-L-E-S. And inside there you can create a bunch of XML files. These are just like the tool dot XML. You copy the tool dot XML, give it a unique name and fill in current values. Hey that's what we've been doing for the last two days to make driver files, right? So basically all you're doing is making a bunch of driver files. So you copy your tool dot XML, you edit it, make it into a driver file and put it in this directory and then you tell the Loader to look for those things there. And the Loader will look in the examples directory, find all the files that match star dot XML and add them onto the Loader menu. So that's it really. If you understand driver files you understand the Loader. It's all we're doing. There's also the case of new. New is a little different because I didn't want it to appear alphabetically. I wanted it to be at the top of the list. So there's a special entry for new. If you don't want to have a new case you don't have to but if you do have a new case you put the tag new and then give it the name new dot XML and it'll be at the top of the list of new. Yeah, question? Yeah, question was the name of the folder is examples and yet the tag is only example. Why is that? It's a little bit historical. What I found there is a difference with yes. The folder has to be called examples and the tag is called example. The reason is because in the early days of Rapture we used to have an example tag and I'd name each one of these files. I'd have an example tag for first dot XML. I have another one for second dot XML. I had another one for both that XML and you can do that. I found it was a nuisance to do that and so I added the idea that I could treat it as a pattern and it would look for all the star dot XMLs and that way as I add new files they automatically get picked up. What I found was I was adding new files for the examples and they wouldn't show up. I have to add the tag in there before they show up. So I added this business of star dot XML and it picks up all of them or you can specify just one of them at a time. Nu is like that too. I'm just specifying one file, the new file. So that's the loader and then the last thing is the default value. I have to say which one when the loader first comes up what's the default example and usually it's the new case but it could be anything and you don't have to have a default. I think in which case the loader does nothing. It won't do anything when you first pop up. So that's it. If you put that XML into your tool dot XML and if you have some example cases set up, you're done. That's all there is to it. Well, almost all. So let me show you again. If I take tool dot XML and I copy it and if I edit it, you put in current values for all the controls that you want. You also need to add a little bit of an about label and a description to the top. That's used by the combo box. The combo box needs to know what do I call this thing. You don't want to give it a weird file name. Instead, you can put whatever label you want like change both and you can even put a description in there too. So as you're creating these example cases, think of them like driver files, except that they also have an about label and description at the top. So if you do that, if you copy your tool dot XML and you create the about section and you add in a few current values, you have an example case for the loader. That's all there is to it. Seriously, that's all there is. I don't think there's anything more. Do I have anything more? That's the description. That's the current values. I guess the one other thing I could say is that if you don't set a current value for a particular control, then it won't change. So you notice remember in the minute ago, I showed you the example of change both. So this is the change both. It's going to change both. But if I only wanted to change one and not the others, then I would just set one current value and not give the other one a current value. In fact, you can even delete stuff that's not being used. Any controls that you don't want to set, you just delete them out of here. So what the loader does is it looks at this file and it matches this file against the tool dot XML. And if it finds a current value for a control in this file and if it can find the corresponding control in the tool dot XML, then it says, oh, set that to that. Oh, here's a current value, set that to that. It just goes through. If it can't find a match, if there's a mismatch, it'll ignore stuff. Or if there's something missing, there's no current values, nothing happens. So copy the tool dot XML, add the about label description, and put in current values for anything that you want change. To change. And that's it. Here's a little bit more complex example of the loader. This is the Resonant Tunneling Diode. And just let me show you real quick how that looks because you can get a better sense of what the loader does. Oops. You go to nano hub. And if I log in and I'm going to run this Resonant Tunneling Diode Simulator. I think it's one of my favorites. Yeah. Okay. So here's an example tool and you can start to recognize some of this stuff now, right? This is a number in Rapture. And I added the presets for a drop down menu. And this is another number, applied bias. And I used a little icon for that. Here are some numbers. This thing is something we haven't talked about yet. It's called a structure. So there are more complicated things in Rapture that we haven't quite talked about yet. Up top is the loader. And the loader has a bunch of different example cases that we can load. I can simulate a one barrier device and you notice the structure changed. I can simulate a three barrier device. And again, you notice the structure changed down below. So when I'm choosing things off the loader, it's changing other controls in the graphical interface. So this is a more complicated example, but it kind of shows you some of the potential of what you can do with the loader. Let me show you another example. It's a little simpler. I'll choose this spice program. So this spice program is a circuit simulator. Again, back from the 1970s. This is sort of a really old program, still useful today. It has a loader at the top. And the loader has the usual new and upload and download. And then it just has a bunch of different cases. I can choose this case and it loads up a script in this string. If I choose this case, it'll load up a different script in this string. So when I'm choosing things off the loader, all it's doing is setting this string. And then when I click simulate, it'll go and run that case. And I can back up now and I can choose a different example and run and it'll run that case and show me the results. So I can simulate lots of different cases off the loader just by picking them off the menu. I do that one already, maybe I'll do this one. And get all these different results. The loader also has the new case, which resets everything to the way it was when the simulation started. So it reminds everybody, enter your input deck here. It's also got built in upload and download. So it can pop up the loader knows how to pop up and prompt me for a file, the spice file that I want to load off my desktop. Or I can copy and paste spice stuff in here. So I can copy and paste in something like hello and upload and now it's there. So that's what the loader is. It's basically a way of loading different example cases, having a new case that clears everything out or uploading and downloading stuff from your desktop. Alright, so that's the loader, the thing up top and it changes the rest of the interface, like I just showed you. Now I showed you that upload download stuff, let me show you the code for how that works. Inside the loader, if you want to be able to upload things into your program, you can add an upload section and you can have multiple two targets. You can say I want to upload into that thing called input.string in-deck and I also want to upload into input.string data file. A lot of times people ask me, hey, my program needs a data file. How do I do it? What's a data file in Rapture? A data file in Rapture is a string. Anything that I suppose just about anything could be a string, but even like if it's a megabyte long or 10 megabytes worth of data, you can treat that as a string in Rapture. And a lot of times when you're expecting people to upload stuff from their desktop into that data file, you can do it like this. You can use the loader and they can choose files from their desktop and upload them into the string, basically. The string you can just think of as a preview where it's showing you what's in the file. So just by adding a section for upload and all the different controls that I want to be able to upload into, I can also add a corresponding section for download and all the things I want to be able to download from. So someone can upload into the data file area and then they can download from the data file area back to their desktop either way. That's useful. I might choose an example and I might say, oh, I want that example. I want to save that example. So I choose the example from the loader and then I download it to my desktop. So just add a little download section and then add the name of the control that you want to be able to download from. Usually it's just one string, but it could be five or six strings or whatever. So that's how those things correspond, those sections correspond to the entries on the menu. Alright, that's the end of the story. That's all there is. But now in order to make it sink in, you guys got to try it. So what we're going to do is we're going to continue with the last lab assignment and we're going to add a loader now into your tool. But remember, you can't use the builder to do this. This time you're on your own. You got to edit your tool.xml code by hand. And it helps if you go to the Rapture website or if you look at the notes in the Rapture website under the documentation and under the GUI XML elements, you can find examples that talk about the loader and how it works. So if you're wondering about this loader and you want to sort of take a look at the code and kind of copy and paste the example code, it's in the documentation or you can use the notes from the course. Either way, but what I want you to do is add a loader up at the top here. You can see right here. I want you to add three cases under the loader. I want you to create a fancy cross case, a flower case, and a palm branch case. And these are the values. If you use 13, negative 7, and negative 3, it'll give you the fancy cross. And then if you use these values, it'll look like a flower. And if you use these, it'll look like a palm branch. So you can add more cases too if you want, but make a loader that has at least those three cases. I didn't use new here. I didn't use upload download. You don't have to. You can just use those three cases in the loader and add that into your tool.xml. Try it out. Alright, so here's my solution for this lab assignment. I wanted to add a loader to the top of the Spirograph program with these three cases. So let me get back into my workspace. So remember, the loader is something that you have, it isn't in the builder. Unfortunately, I apologize for that. It's one of those things I might to do list to integrate that into the builder, because it's the one thing that gives people the most trouble in rapture. But for now, you're going to have to do it by hand. And the way you do it by hand is by editing your tool.xml and adding a little section at the top for the loader. So here's my little definition of the loader. I have a loader with an about label. That gives it a label when it appears on the screen. I set a set of example cases, star.xml, which means anything that it can find.xml in the examples directory. And then I also gave it a default. You might want to set a default like the cross as a good example, or you might not want to. You might have a new option, and the new might be the default. So there are a few different ways to do this. At that point it becomes like a season to taste. Whether or not you wanted to add the new one and whether which one is the appropriate default for your tool, that's up to you. I chose the cross as an example and I didn't have new. I just had a bunch of examples. So the one trick is to make sure that that loader is inside the input section. It's one of the inputs in your program. It's the very top most input. And I usually list it first, although I think if you list it later Rapture will shove it up to the top anyway, but I usually put it right at the top inside the input. So you have to add that to your tool.xml and then save it out. And then we make a directory called examples like that. I've already got one, so let me go into that directory. And you create a file in this directory for each case. So what I do is I copy the tool.xml from above. Let me do one now. I'll create a new case called new.xml. And in that new case I'm going to do two things. First I'm going to look through all of the inputs and I'm going to set a current value. So for each number I'm going to set a current value, current and slash current. Be careful about mismatch tags. And I'll give it a minus 27. And then for this input two, current and slash current. And I'll give it the value 9. And then the next number, current and slash current. And I'll give it the value 31. Okay. Now I have other inputs too. I have this add comments and I have the comment string. I can decide for myself whether or not I want the loader to touch those. If I want the loader to set those then I need to set current values. If I don't set current values then the loader will leave them alone. In fact I can even go further and say I'm just going to get rid of all that. So I could say there goes that and there goes that and I could delete all of that. And again if it's not there the loader ignores it. If it can't find a current value it just does nothing. So whether or not the control is there or whatever. The loader also ignores everything in the output section and the loader also ignores itself. So basically it goes into your tool and it looks in the input section for all the current values it can find and then it sets those current values into your tool. So now I have a new case here and I can save that. And if I go up and run my tool I can see that I've got fancy cross flower palm branch and example number one. What's that example number one? That's the new case I just created. I didn't give it a name. All I did was put a bunch of current values in there. So let me let me fix that. I can edit that new case and at the very top right inside the run I can add an about section with a label. I'll call it extra case. So if I just add that right at the very top just inside the run. See here's my run and here's my about. That describes this case. Now if I run Rapture now fancy cross is the default but there's also an extra case on the list. So that's how you make new examples. And because I set up my program my tool.xml looks for all of the star dot xml's in the examples folder. Whenever I put a new case in that directory it'll automatically get sucked in to my program and it'll show up on the list. I could have been really explicit and instead of a star dot xml like that I could have had a bunch of statements that said fancy dot xml and new dot xml and palm dot xml and all of that. So you can be real explicit with the file names but it's easier just to say star dot xml and then whenever a new file shows up it just gets loaded up into the loader. So that's it. It's the two steps for the loader. I have to add it in to the tool dot xml like that and then I have to create all the different example cases and make sure each of them has current values and about label and then it runs. You notice when you select a case it doesn't do anything much it just changes the values a little bit. So I can select a case and get different values and select this case change my mind and so forth. It's not until I simulate that I get that turned out really good. I got to keep that extra case and then I can simulate again so I can choose a different one and simulate again and then I can flip back and forth between the solutions I guess and see how they look. So that's it. At this point we have a pretty good tool here. We've got a tool that's got a loader at the top it's got some notes it's got groups of model parameters we used enable and disable it's producing results it's a pretty respectable tool and you can put all kinds of really great documentation in so when you click on the link in the notes it pops up the page that brings up the explanation of what that's all about maybe it's a YouTube video you can make a YouTube video and put it out there and link it into your tool that way and point to a lecture on nano hub or maybe a couple of them so that makes a pretty functional tool and the loader is just really nice because it helps people when they're getting started with the tool explore the tool by loading up example cases.