Old 01-12-2015, 01:08 PM   #1
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default EEL : Console debug messages

Hi !

I just made a very useful script for programming eel, based on spk77 code sniped found on this thread :

"name" variable in RPR_EnumProjectMarkers3


I added conditions to display this messages only if the debug variable is set to 1.

Here is a demo :


----
To use this script :
  1. Download it on my GitHub -> REAPER-EEL-Scripts/X-Raym_Functions - console debug messages.eel at master · X-Raym/REAPER-EEL-Scripts
  2. Place it on your script folders
  3. add this code snippet to your script file :
    Code:
    /* DEBUGGING ====> */
    @import X-Raym_Functions - console debug messages.eel
    
    debug = 0; // 0 => No console. 1 => Display console messages for debugging
    /* <=== DEBUGGING */
  4. Use either msg_s, msg_d or msg_f depending on what type of variable datas you want to display (string, double, float)
  5. Adjust debug variable depending on your needs
----
If you want to test this, you can use one of my script which use it (I will progressively convert all my script to handle this) :
REAPER-EEL-Scripts/X-Raym_Snap all regions to grid.eel at master · X-Raym/REAPER-EEL-Scripts

----
Now in LUA for REAPER v5 pre-release:
X-Raym_Functions - console debug messages.lua
---

Happy coding !

Last edited by X-Raym; 02-24-2015 at 05:29 AM.
X-Raym is offline   Reply With Quote
Old 01-12-2015, 06:32 PM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default

code documentation updated (and now working :P)
X-Raym is offline   Reply With Quote
Old 01-19-2015, 01:58 AM   #3
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default Update 1.1

Update 1.1 :
  • Display "ERROR : Empty String" if a string is NULL (prevent auto-non desired-cleaning of the console)
  • Added msg_clean function to reset the console
New code to put a the beginning of your functions :
Code:
// ----- DEBUGGING ====>
//@import X-Raym_Functions - console debug messages.eel

//debug = 0; // 0 => No console. 1 => Display console messages for debugging.
//clean = 0; // 0 => No console cleaning before every script execution. 1 => Console cleaning before every script execution.

//msg_clean();

// <=== DEBUGGING -----

Hope it could help you write some great scripts

EDIT : There was a small bug, it is corrected now !

Last edited by X-Raym; 01-19-2015 at 03:16 AM.
X-Raym is offline   Reply With Quote
Old 01-21-2015, 07:38 AM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default

Hi again !

I made some enhancement to it :P It become serious :P

Code:
msg_start();
to define the start of something in particular (put it under msg_clean()
It will display ▼▼▼▼▼ in the console

Code:
msg_end();
to define the end of an action (put it last in your script file)
it will display▲▲▲▲▲ in the console

Code:
msg_stl(text,variable,line);msg_dtl(text,variable,line);msg_ftl(text,variable,line);
Text parameters display some text in the console before your variable
Variable parameters is the name of the variable you want to debug
Line parameters is a boolean (1 insert a line after the variable, 0 do nothing);
Use the function according to your variable type.

This way for example, if you want to debug a decimal variable, you just have to write this :
Code:
msg_dtl("My variable value:", decimalVariable, 1)
and it will display this in the console :
Code:
My variable value:
0
-----
Of course, all of these support the debug and clean variable already explained before.

Last edited by X-Raym; 01-28-2015 at 06:11 AM.
X-Raym is offline   Reply With Quote
Old 02-01-2015, 05:54 AM   #5
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default msg_tvold !!

Hi !
I know there is some people out there that use this script (they told me in other thread), so let show you a great update to this !

Context :
I had trouble remembering the function name... msg_stl etc... it looks simple but i, practice, it was hard to remember, especially because the order of the letter was not the order of the argument.
I also needed a function that could override the global debug setting. It is useful if there info that have to be displayed, even is debug is set to 0 (such as instructions).

So,

Introducing,
The multipurpose function
msg_tvold(); !

msg_tvolt, has an nice name name for :
Code:
msg_tvold(text,variable,output,line,debug)
Yes, this time, letters are in the order of the argument ! And because the name is more human friendly, it is way easier to remember !

So what msg_tvold can do ?
Here, from the script itself :
Code:
// MULTI PURPOSE FUNCTION
// Text is string
// Variable is your variable
// Output format are string "s", integer "d", and floating point "f"
// Debug value can be overide localy with 0 and 1.
// Line is bolean
//
// Example:
// msg_tvold("My variable", variableString, "s", 1, debug)
// will ouput in the console :
//
// My variable
// *value of variableString* formated into string
// -----
// Only if global debug is set to 1 in file header.
//
// All variables can be set to 0
So yes, you can output your variable, with title text or not, or only text, with a line or not, and override the global debug value.

5 arguments, that's a lot, but because "tvold", you will always remember it :P

Hope you will like it,
for backward compatibility with script written with older functions, all the previous functions are still in the file

Cheers !

Last edited by X-Raym; 02-01-2015 at 07:57 AM.
X-Raym is offline   Reply With Quote
Old 02-01-2015, 07:45 AM   #6
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,750
Default

Very nice X-Raym. Debugging is very important while writing a script.

Maybe it would be good idea to color the debugging functions differently in the notepad++ language file. There are also new functions to include for EEL in REAPER v5
heda is offline   Reply With Quote
Old 02-01-2015, 07:56 AM   #7
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default

@heda
What new functions do you have in mind ?
Can we color the console output text v5 ?

(when v5 will become more official, I will convert this to LUA)
X-Raym is offline   Reply With Quote
Old 02-01-2015, 08:08 AM   #8
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,750
Default

ah sorry I was wrong, you did the walter syntax highlighting and it is spk77 who did the EEL one for notepad++. I was thinking it would be nice to update the file to include new EEL functions too for v5. Your debugging are not official EEL functions but could be colored differently to clearly see those are debugging functions.

by the way... the best way to debug is to use the internal editor in REAPER... But I still like to use Notepad++
heda is offline   Reply With Quote
Old 02-01-2015, 08:22 AM   #9
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default

@heda
Take this UDL :P
hope you like orange.

Agree that future v5 build in editor is a great tool, I must use it more often. But I like my current editors so I stick with them for the moment :P
X-Raym is offline   Reply With Quote
Old 02-01-2015, 02:09 PM   #10
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,750
Default

Thanks. Debugging lines are clearly visible now.
I'm ready for my next scripting adventure
heda is offline   Reply With Quote
Old 02-01-2015, 03:01 PM   #11
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default

@heda
I am very confident about it, your first try was a huge success !
X-Raym is offline   Reply With Quote
Old 02-02-2015, 09:24 AM   #12
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default 1.7

Just updated
Code:
msg_tvold(text,variable,output,line,debug)
with
Code:
%s, %d, %f
to define output format (rather than just the letter), to be conformed with the other functions conventions !
X-Raym is offline   Reply With Quote
Old 02-03-2015, 04:18 PM   #13
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default

I also added
Code:
msg_tvoldi
wich basicaly do the same thing as msg_tvold, but with 6th bolean parameter to allow display text + variable inline, just like this
Code:
Text: Variable
Very useful for debugging incrementation variable, just like this
Code:
J = 1
Cheers !

Last edited by X-Raym; 02-10-2015 at 06:25 AM.
X-Raym is offline   Reply With Quote
Old 02-23-2015, 10:23 AM   #14
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default coverting to lua

I'm trying to convert the script in LUA, it is my first attempt in this language.

I'm pretty close to make it work, but I get an error:
Code:
...EL-Scripts\X-Raym_Functions - console debug messages.lua:171: attempt to call a nil value (global 'strlen')
There must be thing I don't know about declaring variables in LUA; or using the strlen function.

I'm stuck with it so... if you want to contribute:
X-Raym_Functions - console debug messages.lua

Any help is welcome :P

Last edited by X-Raym; 02-24-2015 at 05:03 AM.
X-Raym is offline   Reply With Quote
Old 02-23-2015, 05:29 PM   #15
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,750
Default

hey! I finally know what this is.

strlen() is Lua 4
in Lua 5 it has changed to string.len()

try this

Code:
mystring = "Hello X-Raym!"
long = string.len(mystring);
reaper.ShowConsoleMsg(mystring .. " has " .. long .. " characters")
heda is offline   Reply With Quote
Old 02-24-2015, 05:21 AM   #16
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default LUA release

This works

And more, it leads me to find all the solutions of the other EEL string function conversion!

So here it is: the LUA version of the script !

X-Raym_Functions - console debug messages.lua

Next step, convert my template :P Should be a bit more tricky as there is loop in it, but I have a good feeling. LUA is indeed pretty human friendly

(I know I shouldn't really speak about LUA here but I don't wont to flood the forum with several posts the same thing. It will confuses every one. People who told me they use this scripts are people I know they use pre-release version of REAPER).
X-Raym is offline   Reply With Quote
Old 09-16-2015, 04:19 AM   #17
mduque
Human being with feelings
 
Join Date: Sep 2015
Posts: 25
Default 404

Quote:
Originally Posted by X-Raym View Post
Hi !

I just made a very useful script for programming eel, based on spk77 code sniped found on this thread :

"name" variable in RPR_EnumProjectMarkers3


I added conditions to display this messages only if the debug variable is set to 1.

Here is a demo :


----
To use this script :
  1. Download it on my GitHub -> REAPER-EEL-Scripts/X-Raym_Functions - console debug messages.eel at master · X-Raym/REAPER-EEL-Scripts
  2. Place it on your script folders
  3. add this code snippet to your script file :
    Code:
    /* DEBUGGING ====> */
    @import X-Raym_Functions - console debug messages.eel
    
    debug = 0; // 0 => No console. 1 => Display console messages for debugging
    /* <=== DEBUGGING */
  4. Use either msg_s, msg_d or msg_f depending on what type of variable datas you want to display (string, double, float)
  5. Adjust debug variable depending on your needs
----
If you want to test this, you can use one of my script which use it (I will progressively convert all my script to handle this) :
REAPER-EEL-Scripts/X-Raym_Snap all regions to grid.eel at master · X-Raym/REAPER-EEL-Scripts

----
Now in LUA for REAPER v5 pre-release:
X-Raym_Functions - console debug messages.lua
---

Happy coding !
Tried to download and it's not available ...
mduque is offline   Reply With Quote
Old 09-16-2015, 04:49 AM   #18
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default

@mduque
Hi !

The link is invalid but the download is still avaible online.
Just go on my script pack in my signature, and download it. You will find it in functions subfolder.
When you create a script, create it in the same folder of the functions script.

I rarely use them anymore thanks to the IDE or to simpler function in Lua.
Putting

Code:
function Msg(variavle)
reaper.ShowConsoleMsg(tostring(variable).."\n")
end
is enough in most cases.

But for eel, yes, it can still be useful :P

ps: please don't quote whole post like that, it is very confusing. =/
X-Raym is offline   Reply With Quote
Old 07-06-2016, 10:28 PM   #19
ceanganb
Human being with feelings
 
Join Date: May 2009
Location: Brazil
Posts: 278
Default

This is so great, X-Raym. Getting into scripting without your tools and tutorials would be damn harder. Thanks!

Still I ask you, since you are ´converted´ to Lua, my purposes are both scripting and JSfx (for Lua ain't realtime). Do you think EEL is still good to go for basic/intermediate scripts? So I can avoid learning two languages.
__________________
Ceanganb
ceanganb is offline   Reply With Quote
Old 07-07-2016, 03:49 AM   #20
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default

@ceanganb
Cool ! What kind of script are you working on ?

Lua is so much easier than EEL for scripting that I consider that learning the two languages is simpler than only learning EEL and try to use it for ReaScript.
Because the difficulty is not really in learning the language by itself,
it is to learn the different API (ReaScript API and JSFX API), aka the functions provided by REAPER to allow scripting.

Also, please note than Lua can do "realtime thing", there is a lot of Lua script that have a GUI etc...
The difference is JSFX are for effects (audio or midi) and Lua/EEL are for actions (and these actions can have a "real time" display of something).
X-Raym is offline   Reply With Quote
Old 07-07-2016, 04:57 AM   #21
ceanganb
Human being with feelings
 
Join Date: May 2009
Location: Brazil
Posts: 278
Default

Well, it all began with a little project, copying every CC received in any channel to every other channel. But reading the forums and seeing the potential of customization, I started reading your tutorials and plenty of posts and got interested in going deeper.

Main purpose is still MIDI manipulation in realtime, so I guess I should stick with EEL for now. Maybe after getting used to API, I can think of Lua.

I'm still struggling, but I don't think I can stop now.

By the way, how can I use these debug messages in a JSfx? You see, I'm still stuck in the basics
__________________
Ceanganb
ceanganb is offline   Reply With Quote
Old 07-07-2016, 05:07 AM   #22
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default

@ceanganb
Ok :P

Oh it is for ReaScript, not JSFX,
use the native IDE to have current state of variable with JSFX.
X-Raym is offline   Reply With Quote
Old 07-07-2016, 05:12 AM   #23
ceanganb
Human being with feelings
 
Join Date: May 2009
Location: Brazil
Posts: 278
Default

But in JSFX Programming it says:

"import filename -- REAPER v4.25+
You can specify a filename to import (this filename will be searched within the JS effect directory). Importing files via this directive will have any functions defined in their @init sections available to the local effect."

Can't I adapt? The fact is that I tried many syntaxes and none worked :P
__________________
Ceanganb
ceanganb is offline   Reply With Quote
Old 07-07-2016, 05:16 AM   #24
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default

@ceanganb
It works if the file type are the same,
JSFX can import other JSFX functions form other file,
EEL can import other EEL functions from other file,
But it seems you are trying to import EEL (ReaScript) function into a JSF, so it can't work.

JSFX and EEL may share the same syntax but they don't use the same function and they don't communicate. It is two very different things.
X-Raym is offline   Reply With Quote
Old 07-07-2016, 05:18 AM   #25
ceanganb
Human being with feelings
 
Join Date: May 2009
Location: Brazil
Posts: 278
Default

But I am using your EEL version.
__________________
Ceanganb
ceanganb is offline   Reply With Quote
Old 07-07-2016, 05:20 AM   #26
ceanganb
Human being with feelings
 
Join Date: May 2009
Location: Brazil
Posts: 278
Default

I even tested it in an EEL script and it worked well!
__________________
Ceanganb
ceanganb is offline   Reply With Quote
Old 07-07-2016, 05:28 AM   #27
ceanganb
Human being with feelings
 
Join Date: May 2009
Location: Brazil
Posts: 278
Default

Ops, I misunderstood your statement, sorry. I see now, sorry.

I'll slowly find my way through these intricacies .
Thank you very much, X-Raym!
__________________
Ceanganb
ceanganb is offline   Reply With Quote
Old 07-07-2016, 05:35 AM   #28
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,380
Default

@ceanganb
You have perseverance so I have no doubt you will succeed :P

Good coding !
X-Raym is offline   Reply With Quote
Old 07-07-2016, 05:42 AM   #29
ceanganb
Human being with feelings
 
Join Date: May 2009
Location: Brazil
Posts: 278
Default

I'm slow, but I'll get it

Cheers, pal!
__________________
Ceanganb
ceanganb 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 06:45 AM.


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