AnsweredCAL Script: 'foreach' not finding previous inserted events

Author
rogeriodec
Max Output Level: -75 dBFS
  • Total Posts : 753
  • Joined: 2004/04/09 13:55:04
  • Location: Brazil
  • Status: offline
2018/08/17 22:30:11 (permalink)

CAL Script: 'foreach' not finding previous inserted events

I've learned that with each 'foreach', CAL starts the loop again from the beginning of the selected events.
However, in the code below, I enter some events and in the second foreach loop, they do not appear.


(do
    (int a 0)
    (forEachEvent
         (while (< a 3)
              (do
                  (pause "pass 1:" Event.Kind ";" Event.Time)
                  (insert Event.Time Event.Chan WHEEL a)
                  (++ a)
              )
         )
    )

    (forEachEvent
         (pause "pass 2:" Event.Kind ";" Event.Time)
    )
)

 
How do I get the inserted events to appear for a next foreach?

rogeriodec.com.br


* Cakewalk By Bandlabs (always lastest versions), Window 10 x64
* Focusrite Scarlett Solo Audio Interface
* Intel i7-4790K CPU @ 4.00 GHz / ASROCK EXTREME 4 Z97 Mobo
* 2 SSD Samsung Evo 250 Gb (RAID-0) + 1 Western Digital 2 Tb + 1 Seagate 1 Tb
* Onboard video / 16 Gb RAM HyperX Fury 1600 Mhz
* 3 LCD Monitors
* Axiom 61 MIDI Controller, Tapco S5 Active Studio Monitors
#1
msmcleod
Max Output Level: -72 dBFS
  • Total Posts : 920
  • Joined: 2004/01/27 07:15:30
  • Location: Scotland
  • Status: offline
Re: CAL Script: 'foreach' not finding previous inserted events 2018/08/17 23:33:11 (permalink) ☼ Best Answerby rogeriodec 2018/08/18 00:16:50
Between foreachEvent loops, I found you need to de-select/re-select the track after changing stuff, e.g.:
 
(TrackSelect 0 -1)
(TrackSelect 1 currentTrack)
 
The only downside is "currentTrack" needs to be known. I'm not sure you can programmatically ask what the currently selected track is.
 
The way I've always done it to prompt:
 
(int currentTrack 0)
(getInt currentTrack "Track Number: " 1 255)
 
 
 

Mark McLeod
Cakewalk by BL | ASUS P8B75-V, Intel I5 3570 16GB RAM Win 10 64 + Win 7 64/32 SSD HD's, Scarlett 18i20 / 6i6 | ASUS ROG GL552VW 16GB RAM Win 10 64 SSD HD's, Scarlett 2i2 | Behringer Truth B2030A / Edirol MA-5A | Mackie MCU + C4 + XT | 2 x BCF2000, Korg NanoKontrol Studio
#2
rogeriodec
Max Output Level: -75 dBFS
  • Total Posts : 753
  • Joined: 2004/04/09 13:55:04
  • Location: Brazil
  • Status: offline
Re: CAL Script: 'foreach' not finding previous inserted events 2018/08/18 00:19:08 (permalink)
Although it is not an ideal solution to ask the user to inform the current track, at least this solves the problem.
Thank you!

rogeriodec.com.br


* Cakewalk By Bandlabs (always lastest versions), Window 10 x64
* Focusrite Scarlett Solo Audio Interface
* Intel i7-4790K CPU @ 4.00 GHz / ASROCK EXTREME 4 Z97 Mobo
* 2 SSD Samsung Evo 250 Gb (RAID-0) + 1 Western Digital 2 Tb + 1 Seagate 1 Tb
* Onboard video / 16 Gb RAM HyperX Fury 1600 Mhz
* 3 LCD Monitors
* Axiom 61 MIDI Controller, Tapco S5 Active Studio Monitors
#3
scook
Forum Host
  • Total Posts : 24146
  • Joined: 2005/07/27 13:43:57
  • Location: TX
  • Status: offline
Re: CAL Script: 'foreach' not finding previous inserted events 2018/08/18 00:46:28 (permalink)
(GetCurrentTrack) might help it even if it does not appear to work exactly like the "CAL Reference.chm" bundled with the CAL Editor describes.
#4
rogeriodec
Max Output Level: -75 dBFS
  • Total Posts : 753
  • Joined: 2004/04/09 13:55:04
  • Location: Brazil
  • Status: offline
Re: CAL Script: 'foreach' not finding previous inserted events 2018/08/18 03:42:48 (permalink)
Thank you, but unfortunately, this command does not work.
Maybe it worked before, but not today.
Perhaps that's why it does not appear in the latest documentation.
It returns random values. Try inserting a track, delete it, and then insert it again. He does not respect the number, this is always changing.
Try to reproduce the example here http://forum.cakewalk.com/Finding-the-track-for-a-selection-m278440.aspx) and you'll see. 

rogeriodec.com.br


* Cakewalk By Bandlabs (always lastest versions), Window 10 x64
* Focusrite Scarlett Solo Audio Interface
* Intel i7-4790K CPU @ 4.00 GHz / ASROCK EXTREME 4 Z97 Mobo
* 2 SSD Samsung Evo 250 Gb (RAID-0) + 1 Western Digital 2 Tb + 1 Seagate 1 Tb
* Onboard video / 16 Gb RAM HyperX Fury 1600 Mhz
* 3 LCD Monitors
* Axiom 61 MIDI Controller, Tapco S5 Active Studio Monitors
#5
scook
Forum Host
  • Total Posts : 24146
  • Joined: 2005/07/27 13:43:57
  • Location: TX
  • Status: offline
Re: CAL Script: 'foreach' not finding previous inserted events 2018/08/18 03:59:09 (permalink)
I guess my test was too simple. (GetCurrentTrack) is not returning a random number. It returning what appears to be a unique identifier for the track generated from sequential counter based on the number of tracks created in the project and not the current track number. This is just another reason to avoid CAL. The language was deprecated around 18 years ago. It has been included ever since for backward compatibility. Not really intended for new development.
#6
rogeriodec
Max Output Level: -75 dBFS
  • Total Posts : 753
  • Joined: 2004/04/09 13:55:04
  • Location: Brazil
  • Status: offline
Re: CAL Script: 'foreach' not finding previous inserted events 2018/08/18 05:28:28 (permalink)
scook
This is just another reason to avoid CAL. The language was deprecated around 18 years ago. It has been included ever since for backward compatibility. Not really intended for new development.


I wish there was an alternative!
Unfortunately, AZ Lua (according to the developers themselves) cannot work on a clip selection, only on the entire track. In this way, AZ Lua is practically useless.
Do you know of any other alternatives?
post edited by rogeriodec - 2018/08/18 14:38:15

rogeriodec.com.br


* Cakewalk By Bandlabs (always lastest versions), Window 10 x64
* Focusrite Scarlett Solo Audio Interface
* Intel i7-4790K CPU @ 4.00 GHz / ASROCK EXTREME 4 Z97 Mobo
* 2 SSD Samsung Evo 250 Gb (RAID-0) + 1 Western Digital 2 Tb + 1 Seagate 1 Tb
* Onboard video / 16 Gb RAM HyperX Fury 1600 Mhz
* 3 LCD Monitors
* Axiom 61 MIDI Controller, Tapco S5 Active Studio Monitors
#7
pwalpwal
Max Output Level: -43 dBFS
  • Total Posts : 3249
  • Joined: 2015/01/17 03:52:50
  • Status: offline
Re: CAL Script: 'foreach' not finding previous inserted events 2018/08/18 09:42:03 (permalink)
it has been previously suggested to reboot CAL as PowerShell-scriptable, but Noel said the effort to review and implement the hooks available to powershell makes it not likely

just a sec

#8
rogeriodec
Max Output Level: -75 dBFS
  • Total Posts : 753
  • Joined: 2004/04/09 13:55:04
  • Location: Brazil
  • Status: offline
Re: CAL Script: 'foreach' not finding previous inserted events 2018/08/22 05:45:44 (permalink) ☄ Helpfulby msmcleod 2018/08/22 07:52:17
Analysing the "legato.cal" script, I discovered that, for some reason, these events "flush" the buffer making the previous inserted notes available to the next "foreach": 
 
(if (> From 0)
        (-= From 1)
 
 
 
So, it's much better, once we don't need to ask the current track to the user like the previous solution.

rogeriodec.com.br


* Cakewalk By Bandlabs (always lastest versions), Window 10 x64
* Focusrite Scarlett Solo Audio Interface
* Intel i7-4790K CPU @ 4.00 GHz / ASROCK EXTREME 4 Z97 Mobo
* 2 SSD Samsung Evo 250 Gb (RAID-0) + 1 Western Digital 2 Tb + 1 Seagate 1 Tb
* Onboard video / 16 Gb RAM HyperX Fury 1600 Mhz
* 3 LCD Monitors
* Axiom 61 MIDI Controller, Tapco S5 Active Studio Monitors
#9
Jump to:
© 2024 APG vNext Commercial Version 5.1