Insert name of file

I have an AS that opend and trasform txt document with BBEDIT (i’m newbie, scriptable application :)) in a string test ready to import in a DB.
How can I add the name of file ad the end of the string
I try this
set selection to window name
but bbedit return :
I can set selection of text window 1 a window “001_.txt” of text window 1.

For a start, ‘window name’ is too vague. Although it passes AppleScript’s syntax check, BBEdit can’t understand what you mean.

Instead, try:

tell application "BBEdit"
 	set selection to name of window 1
end tell

Here there’s no doubt as to what you’re referencing - ‘name of window 1’ is precise.

Thanks, works alone but if I insert it into another script code, I have an error massege:
I can’t set selection of text window 1 a name of window 1 of text window 1

tell front text window
select insertion point after last character
set selection to “some text”
select insertion point after last character
set selection to name of window 1
end tell