|
|
|
02-20-2021, 12:28 PM
|
#1
|
Human being with feelings
Join Date: Nov 2009
Posts: 2,227
|
simple undo question
what does the zero mean in this line?
Code:
reaper.Undo_EndBlock( "Description here", 0 )
i've borrowed code from various posted scripts in trying to learn and create some functionality i need and found this line somewhere. meo-ada mespotine posted a link (thanks!) to undo documentation that has lots of options but this option is not listed there. curious.
thanks,
babag
|
|
|
02-20-2021, 02:16 PM
|
#2
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
From the function signature you can see it's the extraflags parameter which schwa has explained here (but strangely isn't documented in the API doc afaik).
|
|
|
02-20-2021, 02:25 PM
|
#3
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
You don't have to use these flags, they're optional.
|
|
|
02-20-2021, 02:36 PM
|
#4
|
Human being with feelings
Join Date: Nov 2009
Posts: 2,227
|
yeah, nofish. no zero in any of the doc i've seen. the schwa post you link indicates that you can sum the flags by adding them, like passing a flag of 5 by summing 1 + 4. there are flags for -1 and 1 which, i'd think, would sum to 0 but, since the -1 flag calls all options, it shouldn't be necessary to add anything to it as far as i can tell. strange.
thanks, vitalker. at this point i just want to know about the zero. maybe i just happened to copy a bit of code that is actually a mistake.
thanks,
babag
|
|
|
02-20-2021, 02:46 PM
|
#5
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Ah yes, 0 isn't there in schwa's explaination, hadn't noticed, sorry.
|
|
|
02-20-2021, 03:11 PM
|
#6
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Quote:
Originally Posted by babag
the schwa post you link indicates that you can sum the flags by adding them, like passing a flag of 5 by summing 1 + 4. there are flags for -1 and 1 which, i'd think, would sum to 0 but, since the -1 flag calls all options, it shouldn't be necessary to add anything to it as far as i can tell. strange.
|
Each flag is a single bit. 0 has all bits cleared, so it specifies none of the possible undo state flags. -1 in binary is all bits set (two's complement) so it specifies all of them (even those that don't exist yet).
Code:
UNDO_STATE_ALL 11111111 11111111 11111111 11111111 ( -1) (or 0xFFFFFFFF, aka 4294967295)
UNDO_STATE_TRACKCFG 00000000 00000000 00000000 00000001 ( 1)
UNDO_STATE_FX 00000000 00000000 00000000 00000010 ( 2)
UNDO_STATE_ITEMS 00000000 00000000 00000000 00000100 ( 4)
UNDO_STATE_MISCCFG 00000000 00000000 00000000 00001000 ( 8)
UNDO_STATE_FREEZE 00000000 00000000 00000000 00010000 ( 16)
UNDO_STATE_TRACKENV 00000000 00000000 00000000 00100000 ( 32)
UNDO_STATE_FXENV 00000000 00000000 00000000 01000000 ( 64)
UNDO_STATE_POOLEDENVS 00000000 00000000 00000000 10000000 (128)
Combining is done by ORing the bits of two or more flags. Addition does the same thing too if both numbers have no set bits in common.
Last edited by cfillion; 02-20-2021 at 03:27 PM.
|
|
|
02-20-2021, 03:14 PM
|
#7
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Quote:
Originally Posted by babag
there are flags for -1 and 1 which, i'd think, would sum to 0 but, since the -1 flag calls all options, it shouldn't be necessary to add anything to it as far as i can tell. strange.
|
It's not addition as such. The flags are a bitfield value, that's why they're all powers of two.
Bitfields are stored in unsigned variables like byte, word, dword etc. and -1 is an invalid value for an unsigned type, so the value wraps around and the variable gets set to its maximum value, all the bits get set to 1, which is why -1 sets all the flags.
Zero just clears all the flags.
Adding flags can get you in a mess if you're not careful. OR is safer because if you accidentally add the same flag twice, it won't matter:
Code:
a = 0;
a = a + 1; // a is 1
a = a + 1; // a is 2
b = 0;
b = b | 1; // b is 1
b = b | 1; // b is still 1
edit: Ha! cfillion posted while I was typing!
|
|
|
02-20-2021, 03:17 PM
|
#8
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Quote:
Originally Posted by nofish
Ah yes, 0 isn't there in schwa's explaination, hadn't noticed, sorry.
|
Actually I think it is easy to understand. All of those numbers are powers of 2, so 0 means none of them.
Quote:
Originally Posted by https://www.reaper.fm/sdk/reascript/reascript.php
undo flags for Undo_EndBlock() et al:
1: track configurations
2: track FX
4: track items
8: project states
16: freeze states
|
|
|
|
02-20-2021, 03:18 PM
|
#9
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Quote:
Originally Posted by IXix
Zero just clears all the flags.
|
What does it mean though? I understood none of the flags is included, but what 0 does to undo block?
|
|
|
02-20-2021, 03:20 PM
|
#10
|
Human being with feelings
Join Date: Nov 2009
Posts: 2,227
|
ok. so, if 0 is none of them, what does it do and why is it used? mistake?
this is getting way beyond my abilities but i did get the bit about summing directly from schwa's post:
Quote:
...you could pass flag=5 (1+4) for example. If your script may have affected everything but freeze state, automation items and ARA state, you could pass flag=111 (1+2+4+8+32+64), etc.
|
he was probably just simplifying for the sake of expediency.
thanks,
babag
|
|
|
02-20-2021, 03:25 PM
|
#11
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Quote:
Originally Posted by vitalker
What does it mean though? I understood none of the flags is included, but what 0 does to undo block?
|
Quote:
Originally Posted by babag
ok. so, if 0 is none of them, what does it do and why is it used? mistake?
|
I would have thought it did nothing. I guess it means you don't care about the flags? Not sure.
|
|
|
02-20-2021, 04:01 PM
|
#12
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
So if 0 does nothing, are these undo-blocks actually not working in that case? Would be kind of weird...
|
|
|
02-20-2021, 04:27 PM
|
#13
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Quote:
Originally Posted by Meo-Ada Mespotine
So if 0 does nothing, are these undo-blocks actually not working in that case? Would be kind of weird...
|
Yeah, I dunno. You'd have to ask the big fellas about that.
|
|
|
02-20-2021, 04:52 PM
|
#14
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Quote:
Originally Posted by IXix
Yeah, I dunno. You'd have to ask the big fellas about that.
|
HELP US JUSTIN-SCHWA-KENOBI! YOU ARE OUR LAST HOPE!
|
|
|
02-21-2021, 05:33 AM
|
#15
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Would be nice then if 0 completely disabled the creation of an undo point in the action history (that would be my expectation from the previous explainations) but I think I've tried it once and it didn't happen.
|
|
|
02-21-2021, 05:46 AM
|
#16
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Quote:
Originally Posted by nofish
Would be nice then if 0 completely disabled the creation of an undo point in the action history (that would be my expectation from the previous explainations) but I think I've tried it once and it didn't happen.
|
Sure, we should have no undo points scripts.
|
|
|
02-22-2021, 02:10 PM
|
#17
|
Human being with feelings
Join Date: Nov 2009
Posts: 2,227
|
so... nothing definitive on the 0? i have a fewe scripts i was waiting to finalize and thought to hold them until i got a final answer on this but, maybe not. would love to know what's up.
thanks,
babag
|
|
|
02-22-2021, 02:12 PM
|
#18
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Quote:
Originally Posted by babag
so... nothing definitive on the 0? i have a fewe scripts i was waiting to finalize and thought to hold them until i got a final answer on this but, maybe not. would love to know what's up.
|
I think if you set 0, it means you use default mode for creating undo points.
|
|
|
02-22-2021, 03:03 PM
|
#19
|
Human being with feelings
Join Date: Nov 2009
Posts: 2,227
|
thanks, vitalker. is that a consensus among everyone here? can't figure out if i should use -1, 0, or just leave it blank.
thanks again,
babag
|
|
|
02-22-2021, 03:07 PM
|
#20
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Quote:
Originally Posted by babag
thanks, vitalker. is that a consensus among everyone here? can't figure out if i should use -1, 0, or just leave it blank.
|
I doubt you can leave it blank. I'd just use 0.
|
|
|
02-22-2021, 03:24 PM
|
#21
|
Human being with feelings
Join Date: Jan 2012
Posts: 1,180
|
It seems to me some actions that don't really change the project like selecting items don't create an undo point. Leaving it blank then works. Other actions do create an undo and then if you leave it blank you get "reascript: run" or something more specific in the undo anyway.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 02:02 AM.
|