Cancel
Showing results for 
Search instead for 
Did you mean: 

WriteFile custom file name

Dear community,

 

it's probably a simple question but i can't figure it out.

I have to write 3 different tables to 3 txt file with the command writefile.

What i want to do is to customize the file name with the date of the simulation, e.g. tab_x_11_08_17.

Below youl'll find the string i'm trying to make it work:

Tab_Dom.WriteFile(getcurrentDirectory+"\04 - Simulation data\Tab_Dom+giorno+mese+anno.txt")

the string is correct because i obtain the file but, of course, the name is: Tab_Dom+giorno+mese+anno.txt

Giorno, mese and anno are day,month and year in italian.

I've made three variables (even if it's useless):

giorno:=num_to_str(day(sysdate))
mese:=num_to_str(month(sysdate))
anno:=num_to_str((year(sysdate)-100))

and they're working too but i do not understand how to put it in the filename.

Thanks for the help.

 

1 REPLY

Re: WriteFile custom file name

Valued Contributor
Valued Contributor

Hi,

 

you can concatenate strings using +

 

e.g.

 

var s : string

s := "a" + "b" + "c"

 

would mean that s = "abc"

 

So in your case, try defining giorno, mese and anno as you did and then concatenate your string like:

 

getcurrentDirectory+"\04 - Simulation data\Tab_Dom" + giorno + mese + anno + ".txt"