Open a generated text file in Notepad++
Open a generated text file in Notepad++
Is it possible, after generating a text file in a program, to get Notepad++ to open the text file for reading?
			
			
									
									
						Re: Open a generated text file in Notepad++
Sure, just use RunProgram()   
 
			
			
									
									
						 
 
Code: Select all
Define Filename$ = "Test.txt"
RunProgram("notepad++", Filename$, "", #PB_Program_Open)
Re: Open a generated text file in Notepad++
Don't forget to enter the full path (classic mistake, if Notepad++ is not in the path)
And if Notepad++ is the default text editor associated with .txt, then the document name is sufficient.
			
			
									
									
						Code: Select all
Define Filename$ = "Test.txt"
RunProgram("C:\Program Files\Notepad++\notepad++.exe", Filename$, "", #PB_Program_Open)Code: Select all
Define Filename$ = "Test.txt"
RunProgram(Filename$, "", "", #PB_Program_Open)Re: Open a generated text file in Notepad++
That's brilliant.  Thanks.  Strangely  
tries to open the 4 parts of the string, and not the file address that the entire string points to...
If I use the method, it opens as default fine.
			
			
									
									
						Code: Select all
f$=fol+"File Explorer - "+fil+".txt"
Debug f$
RunProgram("C:\Program Files\Notepad++\notepad++.exe",f$,fol,#PB_Program_Open)tries to open the 4 parts of the string, and not the file address that the entire string points to...
If I use the
Code: Select all
f$=fol+"File Explorer - "+fil+".txt"
Debug f$
RunProgram(f$, "", "", #PB_Program_Open)Re: Open a generated text file in Notepad++
Might be the space characters
Try
			
			
									
									
						Try
Code: Select all
f$=Chr(34) + fol+"File Explorer - "+fil+".txt" + Chr(34)
Debug f$
RunProgram("C:\Program Files\Notepad++\notepad++.exe",f$,fol,#PB_Program_Open)
Re: Open a generated text file in Notepad++
Code: Select all
EnableExplicit
#ASSOCSTR_EXECUTABLE = 2
#ASSOCF_VERIFY = $40
Procedure.s AssocExe(Ext$, *Act)
    Protected Size, OutRes.s
    AssocQueryString_(#ASSOCF_VERIFY, #ASSOCSTR_EXECUTABLE, @Ext$, *Act, 0, @Size)
    OutRes = Space(Size)
    If AssocQueryString_(#ASSOCF_VERIFY, #ASSOCSTR_EXECUTABLE, @Ext$, *Act, @OutRes, @Size)
        OutRes = ""
    EndIf
    ProcedureReturn OutRes
EndProcedure
Define editor$
editor$ = "C:\Program Files\Notepad++\notepad++.exe"
If Not Asc(editor$) Or FileSize(editor$) < 0
	editor$ = AssocExe(".txt", 0)
	If Not Asc(editor$)
		editor$ = "notepad.exe"
	EndIf
EndIf
RunProgram(editor$, #DQUOTE$ + #PB_Compiler_File + #DQUOTE$, "")Re: Open a generated text file in Notepad++
Yes, that works, thanks.Fips wrote: Sat Mar 15, 2025 8:58 pm Might be the space characters
TryCode: Select all
f$=Chr(34) + fol+"File Explorer - "+fil+".txt" + Chr(34) Debug f$ RunProgram("C:\Program Files\Notepad++\notepad++.exe",f$,fol,#PB_Program_Open)
Re: Open a generated text file in Notepad++
I'm not sure I understand any of this, but why wouldn't I like a Quine?!AZJIO wrote: Sat Mar 15, 2025 10:06 pmCode: Select all
EnableExplicit #ASSOCSTR_EXECUTABLE = 2 #ASSOCF_VERIFY = $40 Procedure.s AssocExe(Ext$, *Act) Protected Size, OutRes.s AssocQueryString_(#ASSOCF_VERIFY, #ASSOCSTR_EXECUTABLE, @Ext$, *Act, 0, @Size) OutRes = Space(Size) If AssocQueryString_(#ASSOCF_VERIFY, #ASSOCSTR_EXECUTABLE, @Ext$, *Act, @OutRes, @Size) OutRes = "" EndIf ProcedureReturn OutRes EndProcedure Define editor$ editor$ = "C:\Program Files\Notepad++\notepad++.exe" If Not Asc(editor$) Or FileSize(editor$) < 0 editor$ = AssocExe(".txt", 0) If Not Asc(editor$) editor$ = "notepad.exe" EndIf EndIf RunProgram(editor$, #DQUOTE$ + #PB_Compiler_File + #DQUOTE$, "")
This a Quine isn't it?
- 
				DarkDragon
- Addict 
- Posts: 2347
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
Re: Open a generated text file in Notepad++
He had no text file ready, so he used the code itself. Just replace #PB_Compiler_File with your text file.matalog wrote: Sun Mar 16, 2025 1:35 amI'm not sure I understand any of this, but why wouldn't I like a Quine?!AZJIO wrote: Sat Mar 15, 2025 10:06 pmCode: Select all
EnableExplicit #ASSOCSTR_EXECUTABLE = 2 #ASSOCF_VERIFY = $40 Procedure.s AssocExe(Ext$, *Act) Protected Size, OutRes.s AssocQueryString_(#ASSOCF_VERIFY, #ASSOCSTR_EXECUTABLE, @Ext$, *Act, 0, @Size) OutRes = Space(Size) If AssocQueryString_(#ASSOCF_VERIFY, #ASSOCSTR_EXECUTABLE, @Ext$, *Act, @OutRes, @Size) OutRes = "" EndIf ProcedureReturn OutRes EndProcedure Define editor$ editor$ = "C:\Program Files\Notepad++\notepad++.exe" If Not Asc(editor$) Or FileSize(editor$) < 0 editor$ = AssocExe(".txt", 0) If Not Asc(editor$) editor$ = "notepad.exe" EndIf EndIf RunProgram(editor$, #DQUOTE$ + #PB_Compiler_File + #DQUOTE$, "")
This a Quine isn't it?
He checks whether notepad++ exists in it's default installation path, if not he tries to get the user's default text editor and if that doesn't work he uses Microsoft notepad.
bye,
Daniel
						Daniel
Re: Open a generated text file in Notepad++
Hi.AZJIO wrote: Sat Mar 15, 2025 10:06 pmCode: Select all
EnableExplicit #ASSOCSTR_EXECUTABLE = 2 #ASSOCF_VERIFY = $40 Procedure.s AssocExe(Ext$, *Act) Protected Size, OutRes.s AssocQueryString_(#ASSOCF_VERIFY, #ASSOCSTR_EXECUTABLE, @Ext$, *Act, 0, @Size) OutRes = Space(Size) If AssocQueryString_(#ASSOCF_VERIFY, #ASSOCSTR_EXECUTABLE, @Ext$, *Act, @OutRes, @Size) OutRes = "" EndIf ProcedureReturn OutRes EndProcedure Define editor$ editor$ = "C:\Program Files\Notepad++\notepad++.exe" If Not Asc(editor$) Or FileSize(editor$) < 0 editor$ = AssocExe(".txt", 0) If Not Asc(editor$) editor$ = "notepad.exe" EndIf EndIf RunProgram(editor$, #DQUOTE$ + #PB_Compiler_File + #DQUOTE$, "")
Thank you AZJIO for the AssocExe Procedure. I needed to find the default browser... and you made it easy for me.
 
 Drone



