Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am trying to assign a name to a captured file

Status
Not open for further replies.

BillWB

Programmer
Mar 28, 2002
1
US
this is the code to build the file name

PRINTCAPTURE ON ; print text sent
mfiledate = getlogname() ; build mmddy
mlgfile = "C:\DATA\MED"
STRCAT mlgfile mfiledate
STRCAT mlgfile ".txt" ; build c:\data\med03282.txt
SET CAPTURE OVERWRITE ON
SET CAPTURE FILE mlgfile ; Set name of capture file.
CAPTURE ON ; Open up the capture file.

FUNC getlogname : STRING
STRING mdate, mm, dd, yy1
STRCPY mm $DATE 2 ; get month into string
SUBSTR dd $DATE 3 2 ; get day into veriable
SUBSTR yy1 $DATE 9 1 ; get single digit year
STRCAT mdate mm
STRCAT mdate dd
STRCAT mdate yy1 ; date mmddy
RETURN mdate
ENDFUNC

However, the file that is built is c:\Program Files\Procomm Plus\bankof02.cap
It is using the first letter of each word in my dialing directory and appending a sequence number to it.
Can anyone help????
 
I don't believe you can use "set capture file" to change the path. Try changing mlgfile to "C:\data". Then use

SET CAPTURE PATH mlgfile

to define the path. Then:

STRCAT newstr "MED" mfiledate

to create the file name. Use

SET CAPTURE FILE newstr

to name the file. Remove the strcat statment that combines the path and file name.

You may also want to use "fetch capture path" to save the original path setting, then at the end use "set capture path" to set the

I tried to change the file type to ".txt" but was unable, I believe your stuck with ".cap".

If it is necessary to use ".txt", Try: (after "set capture off")

chdir "c:\"
chdir "data"
dos "ren MED#####.cap MED######.txt" hidden

Hope this helps!

 
Although the help file doesn't mention it, the set capture file command only sets the filename and cannot accept a path. To set the capture file path, you must use the set capture path command. That is one reason why the expected capture file is not being set.

However, there is another problem as well. The getlogname function is returning 3/8/ (instead of the intended result). This may be due to my machine not having the same short date style that your machine does. If you are still having problems after setting a capture path as mentioned above, then you will need to double check the value returned by the getlogname function. One easy thing you can do if you are just trying to convert the $DATE string to a string without slashes is to assign $DATE to mdate, then use strreplace mdate "/" "" to strip out all of the spaces. This would work better then using the strcpy command.
 
Here is a very simple way to use the current date for a file name. I use this to name a capture file from an automatic session that runs daily. You can then use this name for the capture file command. If you run this it will show you the file name that will me created in the message box. You can also use the format command to format multiple strings into one variable. Hope this helps

rich

________________________

proc main
string mdy ; String in which to replace text.
string pittfilename

mdy = $date ; current system date set to short
strreplace mdy "/" ""
strdelete mdy 4 2
strfmt pittfilename "p%srep.txt" mdy
usermsg $date
usermsg pittfilename ; Display our text string.

endproc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top