How to Localize User Defined Variables?

How to Localize User Defined Variables?

BeKirra
Advisor Advisor
357 Views
2 Replies
Message 1 of 3

How to Localize User Defined Variables?

BeKirra
Advisor
Advisor

As mentioned in title above.

I am wondering if variables can be conflict between codes that are running.

Thanks in advance.

 

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
0 Likes
358 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Hi @BeKirra.  This is an interesting question.  I have not experienced any conflict between variables in different code routines that may be simultaneously running myself, but I can not be 100% sure if it is 'possible' or not.  This may be a good question for one of the Autodesk employees who works closely with Inventor's API & iLogic.  I do know that the iLogic add-in offers us the 'SharedVariable' object, which allows us to store variable based data up into Inventor's 'session memory' temporarily, so that the same data can be accessed by multiple other iLogic rules during that same session of Inventor.  And I do know that system can be mishandled, which could potentially result in problems.  But running multiple user defined/created code resources simultaneously does not seem that common of a situation.  I know we can have multiple event handlers active at the same time, which may qualify for a situation like this, but I have not experienced any issues in that area yet myself.  Not sure about others, but I have not heard of it being an issue while monitoring this forum the last several years.  But I am not on here 24/7, so I could have definitely missed things.

 

Why do you ask?  Do you seem to be experiencing issues that seem like this may be happening?  If so, can you explain it?

 

Edit:  I do know that it is bad practice and problematic to name our variables using exactly the same spelling and capitalization as any of the 'Types' of objects we are working with, or any current 'Keywords' that are being used by the coding language or add-in we may be working with at the time.  But somehow I don't think that is what you meant.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

Frederick_Law
Mentor
Mentor

Normally variables are local by default.  Unless declared shared or global.

Local variables will not conflict with other local variables.  Program/rule cannot see other program/rule local variable.

 

Similar to each sub can have same local variable name.

0 Likes