Saved Bookmarks
| 1. |
Solve : would like to run program source inline? |
|
Answer» HELLO, i WOULD like to create a .bat file that would copy my source into a temporary file and then run that file. for example: right now if have C# program in a file called form.cs and if i run these commands in a .bat file it works fine: csc form.cs form but what i would like to do is run the program the way i currently do it on UNIX, ie something like this: cat > form.cs <<EOF using System; using System.Drawing; using System.Windows.Forms; using System.Data; namespace BindingSourceMultipleForms { public class MainForm : Form { public MainForm() { this.Load += new EventHandler(MainForm_Load); } private BindingSource bindingSource1; private Button button1; private void MainForm_Load(object sender, EventArgs e) { InitializeData(); } EOF form ------------------------------------------- So i'm looking for the DOS command that will encapsulate the source and copy the inline source into a temporary file in essence, ie similar to the UNIX-EOF utility Thanks very much for any pointers or ideas! BobKYou could try this technique 1. delete form.cs if it exists 2. now can use the >> append redirection operator for each source line (simplifies things.) 3. if cannot do above, use > create file redirection operator for first line and >> thereafter BUT - any source line with a & CHARACTER in will cause the command interpreter to bork!! (non-negotiable) e.g. batch code Code: [Select]if exist form.cs del form.cs echo using System;>> form.cs echo using System.drawing;>>form.cs [...] echo {>> form.cs echo InitializeData();>>form.cs echo } >> form.cs csc form.cs form.cs Code: [Select]BUT - any source line with a & character in will cause the command interpreter to bork!! (non-negotiable) so you say that we cant do echo & ?What do you think? (HINT: open a command window and try it.) Quote so you say that we cant do echo & That's correct, but you can use the notation echo ^&. Any character that has meaning in a different context within the shell needs to be escaped with the caret (^). You can even escape the caret itself (^^). Should there be a lot of these characters, your code will look like chicken scratch by the time you're finished! I asked this question in another post but never got a response. Why the batch wrapper? Why not just create form.cs in notepad and use as needed? Adding needless complexities only leads to ERRORS. Sidewinder, you beat me to it regarding escaping the & with a caret. The ampersand (&) has been called the 'poison character' of NT scripting. I believe there are a few situations where escaping is not possible.Yeah, it get really weird with the percent symbol. Using the caret with the % yields nothing, but if you double up with %%, then the results are a single %. Perhaps a KISS certificate should be required of everyone before getting close to a PC. Quote from: Dias de verano on July 22, 2008, 09:54:18 AM What do you think? (Hint: open a command window and try it.) No, i know that i can echo it using ^ char but i was thinking you dont know that Sorry bout that |
|