Send the #Print output to the application window

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
Post Reply
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Send the #Print output to the application window

Post by Tourist Trap »

Hello,

the trick here uses FBIDE. Don't save anything, use quick run to work with the temporary file.
FBIDE temporary source code has its name constant and well known, that's why we use it (it would be really tricky to retrieve the source name at runtime! maybe we could anyway)
I didn't find a better trick to get the results of my intrinsic prints showing up in the application, but there should be. Please don't hesitate if you have an idea. My try anyway is like this (based onnthe documentation for open pipe):

Of course replace the 1st line by your fbc path. Same for FBIDE path later in the code.

Code: Select all

 	#define _fbcExecFilePath            "C:\FreeBasic\FreeBASIC-1.05.0-win32-mingworg\fbc.exe"
    
    #print 
    #print Ok, a little tricky but the intrinsic print shows up here!
    #print (Its normal that the permission is denied, we are using fbidetemp.exe, unless you did otherwise!)
    #print __FILE_NQ__
    #print typeOf(899.133)
    
    width 100
    screen 2
    dim as string	commandString	=> _fbcExecFilePath & " C:\FreeBasic\FBIde0.4.6r4\fbidetemp.bas "
    
    var filenum	=> freeFile()
    dim as string totaltext = ""
	open pipe commandString for input as #filenum
		dim as string	returnString => ""
		do until EOF(filenum)
		    line input #filenum, returnString
            totaltext = totaltext & returnString & chr(10)
		loop
	close #filenum
    ? totaltext
    
    #print ....a little strange , isnt it?!
    
    sleep
    '(eof)
Post Reply