Old 01-24-2018, 03:34 AM   #1
lollo
Human being with feelings
 
Join Date: Jun 2017
Posts: 54
Default www Remote Control GET/PROJEXTSTATE/section/key

Hi guys,

I don't know if this section is right, in case, suggest me where I must to write.

I'm not be able to show in the www_remote_control the string about this command.
I used the command suggest from main.js
[* GET/PROJEXTSTATE/section/key
Returns:
PROJEXTSTATE \t section \t key \t string]

changed it GET/PROJEXTSTATE/storage/text
for my needs.
On Reaper, I'm sure that the string is set because I used:

reaper.SetProjExtState(0,"storage","text","EEEE")

Can someone help me to understand why I'm not be able to show this value in the Browser.

Thx
lollo is offline   Reply With Quote
Old 01-24-2018, 11:41 AM   #2
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

What have you tried? What is the response from REAPER to the GET/PROJEXTSTATE/storage/text request?
cfillion is offline   Reply With Quote
Old 01-24-2018, 01:09 PM   #3
lollo
Human being with feelings
 
Join Date: Jun 2017
Posts: 54
Default

Quote:
Originally Posted by cfillion View Post
What have you tried? What is the response from REAPER to the GET/PROJEXTSTATE/storage/text request?
Hi Cfillion. Thx for your reply.
The key, as I wrote is 'text' and his value is 'EEE'.
This variable/key value is set by lua script, and I would like to recall this value by reaper web control in a simple variable or in a div (JavaScript).
But I can't able :-(
lollo is offline   Reply With Quote
Old 01-25-2018, 02:07 AM   #4
lollo
Human being with feelings
 
Join Date: Jun 2017
Posts: 54
Default

Hi again,

I'm sorry, yesterday I'm been writing by my phone and it doesn't suitable to write long text.

As I said, I tried to set the key'value, but I can not to see the reply from Reaper.
I used:

function wwr_onreply(results) {
var ar = results.split("\n");
var x;
for (x=0;x<ar.length;x++)
{
var tok = ar[x].split("\t");
$('#mydiv').html(ar[0])
}
}

and use this function to call the function

wwr_onreply('GET/PROJEXTSTATE/storage/text')

but in mydiv returns the string as I wrote (GET/PROJEXTSTATE/storage/text)
and not "EEEE" as I had set.

Another test has been:

function wwr_onreply(results) {
var ar = results.split("\n");
var x;
for (x=0;x<ar.length;x++)
{
var tok = ar[x].split("\t");
for (y=0;y<tok .length;y++)
{
$('#mydiv').append(tok[y])
}
}
}

but the result has been the same.
lollo is offline   Reply With Quote
Old 01-25-2018, 01:39 PM   #5
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Don't call wwr_onreply yourself. If you do wwr_onreply('something'), the "results" variable in wwr_onreply will not be set to something else: it'll just be the "something" you gave it.

Code:
// initialization
wwr_start()

// makes an HTTP request to "/_/GET/PROJEXTSTATE/storage/text" in the background
wwr_req('GET/PROJEXTSTATE/storage/text') 

// main.js will call this once a response has been received from the server (REAPER)
function wwr_onreply(results)
{
  // do something with results (the server's response)
  console.log(results)
}

Last edited by cfillion; 01-25-2018 at 02:30 PM.
cfillion is offline   Reply With Quote
Old 01-26-2018, 06:49 PM   #6
lollo
Human being with feelings
 
Join Date: Jun 2017
Posts: 54
Default

Yeah Cfillion!

It works!
I was completely wrong. Wow, you has opened up a world to me!

Many thanks!
lollo is offline   Reply With Quote
Old 01-26-2018, 07:00 PM   #7
lollo
Human being with feelings
 
Join Date: Jun 2017
Posts: 54
Default

Ah, I forgot to ask you if you know the maximun size of the memory allocation of this function, beacause seems that it truncate or not memorize if the string is big too

Thx
lollo is offline   Reply With Quote
Old 01-26-2018, 07:28 PM   #8
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

I wasn't aware of any limitation but I've just tested it: it appears to be 16,383 () characters for GET/PROJEXTSTATE. reaper.GetProjExtState can retrieve the full string. However, when saving the project, it gets truncated in the file to 2^13-(key length)-2 characters. It's truncated again to 2^12-(key length)-2 chars when opening it (subtract 4 instead of 2 to account for the quotes added in the project file if the key contains spaces). Funny how one bit is lost at each step.

Last edited by cfillion; 01-26-2018 at 08:35 PM.
cfillion is offline   Reply With Quote
Old 01-27-2018, 12:49 PM   #9
lollo
Human being with feelings
 
Join Date: Jun 2017
Posts: 54
Default

Thx Cfillion,

do you think that SetExtData (so, no SetProjExtData) has the same limits?
Can you suggest me which method I can use to pass lot of data from Reaper to Browser?
Maybe with txt files and load by JavaScript, but seems an old method...

Thx

Last edited by lollo; 01-27-2018 at 01:13 PM.
lollo is offline   Reply With Quote
Old 01-27-2018, 01:33 PM   #10
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

GET/EXTSTATE doesn't seem to have the same limitation as GET/PROJEXTSTATE. I'm able to retrieve a 1MB-long string with both persist=false and true. It's slow though (~3 secs - curl reports an average download speed of 333k/s).

You could work around GET/PROJEXTSTATE's limitation by splitting the data in 2^12-(key length)-2 sized chunks over multiple keys. Project extstates are saved inside the project file while extstates are not: they're either stored in reaper-extstate.ini (persist=true) or in memory (persist=false).

Last edited by cfillion; 01-27-2018 at 01:44 PM.
cfillion is offline   Reply With Quote
Old 01-27-2018, 01:46 PM   #11
lollo
Human being with feelings
 
Join Date: Jun 2017
Posts: 54
Default

Ok, so maybe is better to use tradition txt to pass the data?

Send an wwr_req('_[script lua to write file txt];GET/PROJEXTDATA/storage/text');

This double method allow me to know when the script (lua) has finished and by wwr_onreplay response I can recall a JavaScript function to load the txt. When The function has load datas, I resent the wwr_req as above.

What do you think?
lollo is offline   Reply With Quote
Old 01-27-2018, 02:02 PM   #12
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Do you need the data to be stored in the project file? Do you want it to persist across REAPER restarts? Or persist when loading a project file?

A text file would be pretty much the same as EXTSTATE: not linked with a project (unless you implement that yourself). (And you'd need an <input type="file">...)
cfillion is offline   Reply With Quote
Old 01-27-2018, 02:18 PM   #13
lollo
Human being with feelings
 
Join Date: Jun 2017
Posts: 54
Default

I want only pass momentarily from reaper to browser some information. Name items, position, length and other parameters. I don't want to save in rpp project, but I only pass these infos.
I thought to use projextdata or extdata to share this info
lollo is offline   Reply With Quote
Old 01-27-2018, 02:20 PM   #14
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Then reaper.SetExtState('section', 'key', 'data', false) and GET/EXTSTATE/section/key is all you need. There is no apparent length limit and the data is stored in memory until deleted or REAPER is closed.
cfillion is offline   Reply With Quote
Old 01-27-2018, 02:28 PM   #15
lollo
Human being with feelings
 
Join Date: Jun 2017
Posts: 54
Default

Understood!
Many thanks. You were very kind to help me.

You have answered to all my doubts.
lollo is offline   Reply With Quote
Old 03-10-2018, 07:01 AM   #16
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by cfillion View Post
I wasn't aware of any limitation but I've just tested it: it appears to be 16,383 () characters for GET/PROJEXTSTATE. reaper.GetProjExtState can retrieve the full string. However, when saving the project, it gets truncated in the file to 2^13-(key length)-2 characters. It's truncated again to 2^12-(key length)-2 chars when opening it (subtract 4 instead of 2 to account for the quotes added in the project file if the key contains spaces). Funny how one bit is lost at each step.
Isn't this a bug? What do you think
spk77 is offline   Reply With Quote
Old 03-10-2018, 12:24 PM   #17
lollo
Human being with feelings
 
Join Date: Jun 2017
Posts: 54
Default

I don't know if it is a bug or not.
I discovered that the strings from browser to Reaper must to be long maximun 1023 characters (with ExtState mode).
Instead from Reaper to browser can be more and more long. I tried with 8000 characters and it works.
If there were a method from browser to Reaper to send more characters, would be fantastic.
lollo is offline   Reply With Quote
Old 03-18-2018, 10:18 AM   #18
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,629
Default

For whom it concerns:
I once wrote me a little programming-introduction for the WebRC:

http://mespotine.de/Ultraschall/Reaper_API_Web.html

maybe it of use for newbies in WebRC-programming.


@lollo
This seems to be some kind of limitation in Lua, but don't know much about that. I just read this here and there about that...
Meo-Ada Mespotine 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 09:11 AM.


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