Old 09-27-2020, 09:35 AM   #1
Hypex
Human being with feelings
 
Join Date: Mar 2015
Location: Australia
Posts: 451
Default Anyway to printf() from an imported script?

Hi.


I've noticed that when you use the "@import" function that debugging the imported EEL script is harder. If you have both windows open in the IDE and run the main script then only the main script has variables listed after a run. Which can get annoying if you have most of your code in another script window and have to switch back to your root script to check the variables. But I found that any printf() calls from the other script disappear into the void. Is there any way to display them? That is apart from merging all the code into one file.


ShowConsoleMsg() works fine. But I need formatting for displaying variable contents. It's hard to debug when not even the old fashioned live printf() will work.


I also found that if your code ends up in an endless loop it can't be broken. Not that I can see. I've ended up in this situation and had to kill the parent Reaper process.
Hypex is offline   Reply With Quote
Old 07-24-2021, 06:34 AM   #2
Hypex
Human being with feelings
 
Join Date: Mar 2015
Location: Australia
Posts: 451
Default

So it's been a while and I still can't determine when printf() actually works. I like to use it to follow variable to functions along with the IDE to check code after a run. I've run my script from the action list. Ran it from the IDE. Loaded all script depends and ran it from the IDE. No output is printed out! What stops printf() working and how do I get it back!? :-?
Hypex is offline   Reply With Quote
Old 07-24-2021, 10:30 AM   #3
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
Default

You have sprintf that prints to a string, https://www.reaper.fm/sdk/js/strings...s_string_funcs. That string you can then show in the console using ShowConsoleMsg().
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is online now   Reply With Quote
Old 07-24-2021, 07:14 PM   #4
Hypex
Human being with feelings
 
Join Date: Mar 2015
Location: Australia
Posts: 451
Default

Quote:
Originally Posted by Fabian View Post
You have sprintf that prints to a string, https://www.reaper.fm/sdk/js/strings...s_string_funcs. That string you can then show in the console using ShowConsoleMsg().

Yes I could do that. I might need to some time soon. Since printf() is going random and not printing anything. I may have to divert it with ShowConsoleMsg(). I do wonder if it's because an output window has gone missing and disappeared. I find the Reaper windows hard to manage as there is no obvious window list management and when changing focus such as going to a web browser briefly then coming back to Reaper it puts another window in front. In the meantime got it working again by quitting Reaper and reloading it.
Hypex is offline   Reply With Quote
Old 07-25-2021, 12:40 PM   #5
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
Default

I am not sure that I understand your problem... are you talking about gfx_printf() "going random"? You have to set gfx_x and gfx_y before calling gfx_printf() to print at your preferred position.

The issue you describe... Is the problem that your script window is not being focused after you have switched to another app and back to Reaper?
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is online now   Reply With Quote
Old 07-26-2021, 02:29 AM   #6
Hypex
Human being with feelings
 
Join Date: Mar 2015
Location: Australia
Posts: 451
Default

No I'm describing the generic printf() running from an EEL script in the IDE. That outputs to the ReaScript Error Console window. It's disappeared again. I'll need to reload again to get it working.


That's the main issue. The other issue which is more an annoyance is that Reaper doesn't activate the window I was editing with. I don't know it's changing the order.


I thought the console window may have gone off screen and I just couldn't see it. But I'm really just making excuses for why it doesn't appear. If it's still open I need to close it or Reaper blocks. So that would cancel it going out of view. I think it just must be a bug as I can't see any way I am stopping it from working.
Hypex is offline   Reply With Quote
Old 12-25-2021, 10:54 PM   #7
Hypex
Human being with feelings
 
Join Date: Mar 2015
Location: Australia
Posts: 451
Default

I don't believe it but I am still stuck on this. Without being able live debug I rely on printf() output after a code run. But I cannot rely on it working. I just cannot seem to crack it. It either prints output or it doesn't.


I've opened one window to start a script from and it had worked. But now when doing the same it doesn't work! It's as if some state in Reaper corrupts and it will refuse to work until it's quit and restarted.


I've found Reaper can go corrupt in other ways. Such as the time clock displaying large numbers. Or the cursor and view not moving on playback. So I wouldn't be surprised if something kills off printf(). I just don't know what it is! :-?
Hypex is offline   Reply With Quote
Old 12-29-2021, 11:40 AM   #8
jrk
Human being with feelings
 
Join Date: Aug 2015
Posts: 2,969
Default

EEL printf goes to - a "system-specific destination" - according to the docs. That's sufficiently vague that I guess you shouldn't count on it.

Like you say, ShowConsoleMsg() is guaranteed to go to console, so that's got to be the better choice.
Code:
ShowConsoleMsg(sprintf(#, your_format, your_args))
Or a debug function along those lines - perhaps more useful.
__________________
it's meant to sound like that...
jrk is offline   Reply With Quote
Old 12-29-2021, 11:27 PM   #9
Hypex
Human being with feelings
 
Join Date: Mar 2015
Location: Australia
Posts: 451
Default

Quote:
Originally Posted by jrk View Post
EEL printf goes to - a "system-specific destination" - according to the docs. That's sufficiently vague that I guess you shouldn't count on it.

I found I can't. I had a script run that worked fine. Did some editing and the output stopped showing up. So then quit it and reopened Reaper. Load main script and run. Output comes back. :-?


Quote:
Like you say, ShowConsoleMsg() is guaranteed to go to console, so that's got to be the better choice.

I'm starting to think so. One issue with printf() method is it isn't live as the output is printed when it stops. One of these days I'm going to investigate the possibility of a live debugger. :-)


Quote:
Code:
ShowConsoleMsg(sprintf(#, your_format, your_args))
Or a debug function along those lines - perhaps more useful.

Cheers. Yes good idea. What I should have done is write an actual DebugF() or something but I only needed temporary output then it got out of hand. :-D
Hypex is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:02 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.