02-17-2007 02:36 PM
02-17-2007 03:53 PM
Let me try to summarize all the suggestions in this project:
1. scomack system relies on an external file to hold the last file written permitting you to automatically generate a name with a progressive index. It can be easily customized to permit creation of a filename significant to you
2. CreateAndOpenTemporaryFile does the same thing without need for an external file to hold the index of the last file created; it creates a different filename, though, maybe in a slightly less rigid way than in scomack one
3. FileSelectPopup permits the user to navigate in system resources and choose both filename and directory (even on remote systems or remvable drives)
4. Finally, a simple PromptPopup can be enough to permit the user to set the name of the output file
You may choose the system that better fits to the desired level of flexibilty and/or complexity your application requires.
02-20-2007 08:58 AM
02-20-2007 09:08 AM
Here your function rewritten to write in one file all your data. Error checking must be added looking at return values for OpenFile and WriteLine.
if (userResponse == TRUE) {
int fH = 0;
char msg[512];
fH = OpenFile (REPORT_NAME, VAL_WRITE_ONLY, VAL_TRUNCATE, VAL_ASCII);
WriteLine (fH,"Report \nUser ID: 123456\n Date,Time,Notes",-1);
while (n < 20) {
sprintf (msg,"%s,[%s] ,%f,%f,This is the test comment under notes",DateStr (), TimeStr (),CO,BV);
// NOTE: Where are the differences between the lines? There is no data dependind on "n" here! <=====
WriteLine (fH,msg,-1);
n++;
}
WriteLine (fH,msg,-1);
CloseFile (fH);
}
02-20-2007 09:42 AM
02-20-2007 10:01 AM
To generate rando numbers you can use SetRandomSeed and Random from the Programmer's toolbox. This tool (toolbox.fp) is located in <cvidir>\toolslib\toolbox and can be loaded either in the Instrument menu or in the Library menu. I personally prefere the second option since I use extensively its function throughout my programs, but you can decide to operate in either way.
Look at online help for these functions and execute the following lines in the interactive window. Note that these functions return a pseudo-random series of numbers, depending on the random seed used. On slow processes normally you can randomize every time against Timer () value which is changing, but on tight loops as yours this is not relevant (Timer returns milliseconds, while your loop should terminate in less than one msec).
#include <utility.h>
#include "toolbox.h"
static int i;
SetRandomSeed (Timer ());
for (i = 0; i < 20; i++) {
DebugPrintf ("%s,[%s] ,%f,%f,This is the test comment under notes\n",DateStr (), TimeStr (),
Random (0.5, 3.0),Random (0.5, 3.0));
}
02-20-2007 10:19 AM
02-20-2007 10:42 AM
02-20-2007 10:44 AM
02-20-2007 10:57 AM