Comments (7)
uh oh :/
Let me take a look.
from sublimeksp.
Actually I don't think this is a new bug. Have you only just started using a divide in the define value? It's bad news if this update is breaking people's code, but I'm not sure that that is the case.
Nevertheless, a silly bug to miss, I will fix this tomorrow.
from sublimeksp.
No, it was working fine earlier.
Here is an example line:
define NUM_ARTIC_PGS_KEYS := ((DATA_ARRAY_SIZE / PGS_MAX_KEY_LENGTH) + ((DATA_ARRAY_SIZE % PGS_MAX_KEY_LENGTH)+(PGS_MAX_KEY_LENGTH-1))/PGS_MAX_KEY_LENGTH)
Without getting into nitty gritty implementation details (not discussing design practices, just showing code that is breaking) or why I wrote this code the way it is, what's happening is that it's finding the next factor up from the size of the data array as a multiple of PGS key length.
For example, 2048 size would create 16 PGS keys, while 2049 (all the way up to 2176) size would make 17 PGS keys to accommodate the data. The idea is we might be defining different data sizes per project, and so it's nice to use iterate macro to create and update pgs keys for transferring this data array instead of manually adding and removing them each project.
I know it seems like an absurd thing to want to do but the easiest specific example I could provide is something I'm actually doing. :)
ANYWAYS, the point is this compiled fine a week ago, and worked beautifully.
Example program:
on init
define ARTIC_MATRIX_SIZE := 2112
define PGS_MAX_KEY_LENGTH := 128
declare ARTIC_MATRIX[ARTIC_MATRIX_SIZE]
articulations.ui.createPGSKeys
articulations.ui.updatePGSKeys
end on
define ITERATES.ON_PGS_KEY_NUMS := #0 to ((ARTIC_MATRIX_SIZE / PGS_MAX_KEY_LENGTH) + ((ARTIC_MATRIX_SIZE % PGS_MAX_KEY_LENGTH)+(PGS_MAX_KEY_LENGTH-1))/PGS_MAX_KEY_LENGTH) - 1#
macro articulations.ui.createPGSKeys()
iterate_macro(pgs_create_key(ARTIC_PGS#n#, PGS_MAX_KEY_LENGTH)) := ITERATES.ON_PGS_KEY_NUMS
end macro
macro articulations.ui.updatePGSKeys()
declare i
for i := 0 to PGS_MAX_KEY_LENGTH - 1
iterate_macro(send_PGS_key) := ITERATES.ON_PGS_KEY_NUMS
end for
end macro
macro send_PGS_key(#n#)
if #n#*PGS_MAX_KEY_LENGTH + i < ARTIC_MATRIX_SIZE
pgs_set_key_val(ARTIC_PGS#n#, i, ARTIC_MATRIX[#n#*PGS_MAX_KEY_LENGTH + i])
end if
end macro
and compiled result:
{ Compiled on Fri Jul 1 11:05:56 2016 }
on init
declare %ARTIC_MATRIX[2112]
pgs_create_key(ARTIC_PGS0,128)
pgs_create_key(ARTIC_PGS1,128)
pgs_create_key(ARTIC_PGS2,128)
pgs_create_key(ARTIC_PGS3,128)
pgs_create_key(ARTIC_PGS4,128)
pgs_create_key(ARTIC_PGS5,128)
pgs_create_key(ARTIC_PGS6,128)
pgs_create_key(ARTIC_PGS7,128)
pgs_create_key(ARTIC_PGS8,128)
pgs_create_key(ARTIC_PGS9,128)
pgs_create_key(ARTIC_PGS10,128)
pgs_create_key(ARTIC_PGS11,128)
pgs_create_key(ARTIC_PGS12,128)
pgs_create_key(ARTIC_PGS13,128)
pgs_create_key(ARTIC_PGS14,128)
pgs_create_key(ARTIC_PGS15,128)
pgs_create_key(ARTIC_PGS16,128)
declare $i
$i := 0
while ($i<128)
if (0+$i<2112)
pgs_set_key_val(ARTIC_PGS0,$i,%ARTIC_MATRIX[0+$i])
end if
if (128+$i<2112)
pgs_set_key_val(ARTIC_PGS1,$i,%ARTIC_MATRIX[128+$i])
end if
if (256+$i<2112)
pgs_set_key_val(ARTIC_PGS2,$i,%ARTIC_MATRIX[256+$i])
end if
if (384+$i<2112)
pgs_set_key_val(ARTIC_PGS3,$i,%ARTIC_MATRIX[384+$i])
end if
if (512+$i<2112)
pgs_set_key_val(ARTIC_PGS4,$i,%ARTIC_MATRIX[512+$i])
end if
if (640+$i<2112)
pgs_set_key_val(ARTIC_PGS5,$i,%ARTIC_MATRIX[640+$i])
end if
if (768+$i<2112)
pgs_set_key_val(ARTIC_PGS6,$i,%ARTIC_MATRIX[768+$i])
end if
if (896+$i<2112)
pgs_set_key_val(ARTIC_PGS7,$i,%ARTIC_MATRIX[896+$i])
end if
if (1024+$i<2112)
pgs_set_key_val(ARTIC_PGS8,$i,%ARTIC_MATRIX[1024+$i])
end if
if (1152+$i<2112)
pgs_set_key_val(ARTIC_PGS9,$i,%ARTIC_MATRIX[1152+$i])
end if
if (1280+$i<2112)
pgs_set_key_val(ARTIC_PGS10,$i,%ARTIC_MATRIX[1280+$i])
end if
if (1408+$i<2112)
pgs_set_key_val(ARTIC_PGS11,$i,%ARTIC_MATRIX[1408+$i])
end if
if (1536+$i<2112)
pgs_set_key_val(ARTIC_PGS12,$i,%ARTIC_MATRIX[1536+$i])
end if
if (1664+$i<2112)
pgs_set_key_val(ARTIC_PGS13,$i,%ARTIC_MATRIX[1664+$i])
end if
if (1792+$i<2112)
pgs_set_key_val(ARTIC_PGS14,$i,%ARTIC_MATRIX[1792+$i])
end if
if (1920+$i<2112)
pgs_set_key_val(ARTIC_PGS15,$i,%ARTIC_MATRIX[1920+$i])
end if
if (2048+$i<2112)
pgs_set_key_val(ARTIC_PGS16,$i,%ARTIC_MATRIX[2048+$i])
end if
inc($i)
end while
end on
(granted I have changed the details of how the program works and optimized it and made some corrections, but the core method is the same, using defines and division and such)
from sublimeksp.
So it did work before, but now it does not. Now it compiles to error, because those define constants are now placing decimals.
from sublimeksp.
PGS variables are limited by their size so that's a cool way to work around that :)
Whatever has happened, I am confident that this bug is not a result of the latest update. The culprit is a line that evaluates the define statement's value as a python expression which foolishly of course can result in floats when doing division. But this line has been present for many releases, if one was so inclined this can be checked in github release history.
Somehow it has surfaced itself over time, which I am pleased because this one is a nasty one!
from sublimeksp.
Strange that it wasn't an issue before. It can't be my own error, as I showed a program did properly compile with these very operations. The only thing scarier than not knowing why something doesn't work is not knowing why it works. D:
Good to know you found the culprit line, though. Can put it to rest, at least.
from sublimeksp.
This is going to take longer to fix than I thought.
In the mean while, if you are desperate to get it back working again, you could use the python function int() to make your divides cast to integers. Like: int(ARTIC_MATRIX_SIZE / PGS_MAX_KEY_LENGTH)
This is a bit hacky and I can't guarantee that this will still work after the update, but might be useful if you need it now.
from sublimeksp.
Related Issues (20)
- Traceback Error - Upgraded package from 1.12.2 to 1.15.0 HOT 2
- Allow combinable callbacks in macros HOT 2
- UI array parsing breaks when putting pers after ui_control
- Raise error with duplicate defines
- In-line Literate_macro not allowing literals inside strings
- Another issue with Combine Callbacks option
- Autocomplete adds arguments for macros/functions
- Inline multi-line functions HOT 1
- Compilation does not take into account changes to files until they are saved. HOT 3
- Catch instances of built-in functions being used in prohibited callbacks HOT 1
- "Optimize Compiled Code" option broken for HIDE_PART_BG .or. HIDE_PART_VALUE HOT 3
- SublimeKSP Autocomplete Issue: NIKontakt Variables vs. User Variables HOT 2
- Add a .SIZE define for literal defines #416 is not working HOT 3
- new "branch optimisation" breaks existing projects HOT 2
- Improve error dialog for UICB parsing
- Enable importing .ksp files from folders (#400) broke some imports here (possible old math library related) HOT 4
- optimize_code pragma is not working HOT 2
- Incorrect error message for undeclared struct field HOT 1
- Type casting issue: script runs in Kontakt 7 but fails to compile in Sublime KSP HOT 3
- Compilation error when declaring a local 2D array in a function HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sublimeksp.