From: CyberFrog on 7 Jul 2010 18:10 Hi all, General question: I have some code at the moment that uses the fopen command to print numerous lines to a file i.e. fprintf (fidh,'********************************\n'); fprintf(fidh,'\n'); fprintf(fidh,'This); fprintf(fidh,'that\n'); fprintf(fidh,'etc etc etc....'); Now what I would like to do in the code is once it here is to write these lines to a file or text box that pops up to the user and allows the users to make any further changes that has not been included already. Once the user has finished they can then press a button to continue which will not only save the editted file but continue within the code. How is best to write data to an text box that will eventually pop up to a user anyway, I'm assuming these fprintf statements will have to be replaced? Thanks CF
From: Walter Roberson on 7 Jul 2010 18:18 CyberFrog wrote: > I have some code at the moment that uses the fopen command to print > numerous lines to a file i.e. > > fprintf (fidh,'********************************\n'); > fprintf(fidh,'\n'); > fprintf(fidh,'This); > fprintf(fidh,'that\n'); > fprintf(fidh,'etc etc etc....'); > > Now what I would like to do in the code is once it here is to write > these lines to a file or text box that pops up to the user and allows > the users to make any further changes that has not been included > already. Once the user has finished they can then press a button to > continue which will not only save the editted file but continue within > the code. > > How is best to write data to an text box that will eventually pop up to > a user anyway, I'm assuming these fprintf statements will have to be > replaced? You could memmap() the file, leave the fprintf() statements in place, and then extract the resulting string from memory. Not saying that's a spiffy way, but it might beat rewriting lots of code.
From: Image Analyst on 7 Jul 2010 22:02 CyberFrog: What operating system are you using? If you're using windows, you can issue this command !notepad 'C:\My Folder\mytextFile.txt'; Unfortunately it appears that you have to pass the exact name of the file as a literal string - it does not appear to accept variables like !notepad fileName;
From: CyberFrog on 8 Jul 2010 05:03 "Image Analyst" <imageanalyst(a)mailinator.com> wrote in message <i13biu$adv$1(a)fred.mathworks.com>... > CyberFrog: > What operating system are you using? If you're using windows, you can issue this command > > !notepad 'C:\My Folder\mytextFile.txt'; > > Unfortunately it appears that you have to pass the exact name of the file as a literal string - it does not appear to accept variables like > > !notepad fileName; Sorry its actually going to be used on Linux? Thanks
From: Jan Simon on 8 Jul 2010 06:59
Dear CyberFrog, > I have some code at the moment that uses the fopen command to print numerous lines to a file i.e. > > fprintf (fidh,'********************************\n'); > fprintf(fidh,'\n'); > fprintf(fidh,'This); > fprintf(fidh,'that\n'); > fprintf(fidh,'etc etc etc....'); > > Now what I would like to do in the code is once it here is to write these lines to a file or text box that pops up to the user and allows the users to make any further changes that has not been included already. Why not trying it the other way around: Write the file and open its context in a multi-line edit field: fprintf... fclose(fidh); CStr = textread(FileName, '%s', 'delimiter', '\n'); EditH = uicontrol('Style', 'edit', 'Units', 'normalized', ... 'Position', [0, 0.1, 1, 1], 'Max', 2, 'String', CStr, ... 'HorizontalAlignment', 'left'); ReadH = uicontrol('Style', 'pushbutton', 'Units', 'normalized', ... 'Position', [0,0,1,0.1], 'String', 'ready', ... 'Callback', 'set(gcbo, ''Visible'', ''off'')); waitfor(gcf, 'Visible'); modifiedCStr = get(EditH, 'String'); This waits until the user hits the (ugly - please choose a nicer layout...) button. Good luck, Jan |