# IDE Scripts Do Not Seem To Change Declarations For Methods 

**URL:** <https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086>\
**Category:** General\
**Created:** [June 23, 2015, 11:06am UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086 "2015-06-23T11:06:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oliver\_Scott-Brown](https://forum.xojo.com/letter_avatar_proxy/v4/letter/o/8baadc/32.png) [@Oliver\_Scott-Brown](https://forum.xojo.com/u/Oliver_Scott-Brown)\
**Post date:** [June 23, 2015, 11:06am UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/1 "2015-06-23T11:06:39Z")

</div>

If I use the following code, it will work.

```auto
DoCommand("NewProperty")
ChangeDeclaration("UserName", "Bob Roberts",
"String", 2, "")
```

But it seems to not work with methods so if I replace ‘Property’ with ‘Method’ in this code then it will not work.

Thanks

---

<div class="post-metadata">

**Author:** ![Eli\_Ott](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/5f8ce5/32.png) [@Eli\_Ott](https://forum.xojo.com/u/Eli_Ott)\
**Post date:** [June 23, 2015, 11:17am UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/2 "2015-06-23T11:17:46Z")

</div>

Try as an example:

`DoCommand("NewMethod")
ChangeDeclaration("IsPointValid", "x As Integer, y As Integer", "Boolean", 2, "")`  
It will create this method body:

[code]Private Function IsPointValid(x As Integer, y As Integer) As Boolean

End Function[/code]

---

<div class="post-metadata">

**Author:** ![Oliver\_Scott-Brown](https://forum.xojo.com/letter_avatar_proxy/v4/letter/o/8baadc/32.png) [@Oliver\_Scott-Brown](https://forum.xojo.com/u/Oliver_Scott-Brown)\
**Post date:** [June 23, 2015, 11:30am UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/3 "2015-06-23T11:30:51Z")

</div>

[quote=196170:@Eli Ott]Try as an example:

`DoCommand("NewMethod")
ChangeDeclaration("IsPointValid", "x As Integer, y As Integer", "Boolean", 2, "")`  
It will create this method body:

[code]Private Function IsPointValid(x As Integer, y As Integer) As Boolean

End Function[/code][/quote]  
Didn’t seem to work. Thanks

---

<div class="post-metadata">

**Author:** ![Jeremy\_Cowgar](https://forum.xojo.com/user_avatar/forum.xojo.com/jeremy_cowgar/32/4590_2.png) [@Jeremy\_Cowgar](https://forum.xojo.com/u/Jeremy_Cowgar)\
**Post date:** [June 24, 2015, 2:06am UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/4 "2015-06-24T02:06:46Z")

</div>

Can’t change constants either. \<[https://xojo.com/issue/33310](https://xojo.com/issue/33310)\>

---

<div class="post-metadata">

**Author:** ![Eric\_Brown2](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ad7895/32.png) [@Eric\_Brown2](https://forum.xojo.com/u/Eric_Brown2)\
**Post date:** [July 14, 2015, 9:00pm UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/5 "2015-07-14T21:00:55Z")

</div>

Oliver,

Did you ever find a solution to this? If not, did you file a feedback report? I’m running into the same issue…

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [July 14, 2015, 9:20pm UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/6 "2015-07-14T21:20:26Z")

</div>

I have to admit I’m very curious about what it is you guys are trying to achieve with IDE scripting.  
Seems like you’re writing code to write code ?

IDE scripting is, for 99% of the uses, a simple way to automate things you might do manually - mostly to be able to build a project (which is mostly how it started out)  
It doesn’t provide full access to the entire project & all its elements nor was it designed to.

---

<div class="post-metadata">

**Author:** ![Eric\_Brown2](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ad7895/32.png) [@Eric\_Brown2](https://forum.xojo.com/u/Eric_Brown2)\
**Post date:** [July 14, 2015, 9:33pm UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/7 "2015-07-14T21:33:59Z")

</div>

[quote=200437:@Norman Palardy]I have to admit I’m very curious about what it is you guys are trying to achieve with IDE scripting.  
Seems like you’re writing code to write code ?

IDE scripting is, for 99% of the uses, a simple way to automate things you might do manually - mostly to be able to build a project (which is mostly how it started out)  
It doesn’t provide full access to the entire project & all its elements nor was it designed to.[/quote]

Well, on one part you’re right; on the other… according to the PDF on it:

“Generally this is used to rename a property or method after it has  
been added to a project item.”

So, it should work. About your statement though… I am using it to ‘write’ code. As with most of the topics using ideScript on here when searching for issues I’m having, they (as well as I) am using flags in my string (ie. “[!]this is my string[!]”) and attempting to create an ideScript which will pull all those out and replace them with obfuscated data. I’m actually going a step further and replacing them with an encrypted hex value, and using something like:

`dim a as text
a = convertData("[!]this is my string[!]")`

in the convertData method, I check if debugBuild is true. If it is, I just use replaceAll “[!]” to “”. If it’s not, I pass it through a decryption method (because by then, the string between the flags should be encrypted in hex format). It’s this process of pulling out the strings within the flags, using an external application I made to pass the string values to, and replacing it with stdOut of that, that I am attempting.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [July 14, 2015, 9:53pm UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/8 "2015-07-14T21:53:29Z")

</div>

IDE script has no decent way to walk over all the items in your project, and all the constants, methods, etc etc in each item so you can reliably process EVERY item in your project which is what it sounds like you need.  
Thats one issue.

Not sure if you’re using constants for these or not but with constants you have no way to manipulate each localized value - only the default.

Personally I’d  
a) use a constant (hexed or not)  
b) always call convertdata and have its internals know debugbuild or not and do the right thing  
c) change the value of the constants only to the hexed / unhexed versions as needed

That way you minimize the amount of code that changes between a debug run and actual build

Changing data should be ok as the code doesn’t change.  
Changing compilable code after debugging the code is often a recipe for differences in a release vs debug builds that are truly a pain in the butt to track down. Been there done that have the scars from having this occur in building the IDE itself.

That said there IS, somewhere, an FR for making IDE script able to walk over the project and its contents so doing scripted changes to projects could be simpler with an external tool like you’re trying to do

But thats about the best I can suggest at this point

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [July 14, 2015, 9:55pm UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/9 "2015-07-14T21:55:04Z")

</div>

Alternatively you could write ONE module with all these constants in it and process if you use VCP format  
Or use the code gen classes I wrote ages ago & use them to generate a new module.  
Then simply replace a “debug build” module with the other “release module”

---

<div class="post-metadata">

**Author:** ![Eric\_Brown2](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ad7895/32.png) [@Eric\_Brown2](https://forum.xojo.com/u/Eric_Brown2)\
**Post date:** [July 14, 2015, 10:38pm UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/10 "2015-07-14T22:38:27Z")

</div>

[quote=200452:@Norman Palardy]Alternatively you could write ONE module with all these constants in it and process if you use VCP format  
Or use the code gen classes I wrote ages ago & use them to generate a new module.  
Then simply replace a “debug build” module with the other “release module”[/quote]

That’s actually what I have been doing. I’m just attempting to tackle this using ideScript to ‘see if it’s possible’. I know it’s not feasible or designed for this… but damnit, I’m determined. 😛

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [July 14, 2015, 11:54pm UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/11 "2015-07-14T23:54:44Z")

</div>

Buy steel toed boots  
Your toes will appreciate them 😛

---

<div class="post-metadata">

**Author:** ![Oliver\_Scott-Brown](https://forum.xojo.com/letter_avatar_proxy/v4/letter/o/8baadc/32.png) [@Oliver\_Scott-Brown](https://forum.xojo.com/u/Oliver_Scott-Brown)\
**Post date:** [July 19, 2015, 12:11pm UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/12 "2015-07-19T12:11:07Z")

</div>

What I was trying to achieve with IDE scripts is, giving me the ability to select an array property and then have the script automatically add methods similar to getters and setters but for arrays. It would add myVar\_Append, myVar\_Ubound, myVar\_Item, myVar\_Remove, etc. If this single bug was fixed I believe it would be easy to automate this.

---

<div class="post-metadata">

**Author:** ![Mike\_D](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_d/32/266_2.png) [@Mike\_D](https://forum.xojo.com/u/Mike_D)\
**Post date:** [July 19, 2015, 2:35pm UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/13 "2015-07-19T14:35:46Z")

</div>

Oliver, not sure what you are trying to accomplish but you can do something similar using the Extends keyword:  
[http://documentation.xojo.com/index.php/Extends](http://documentation.xojo.com/index.php/Extends)

Generally, if you find yourself writing (by hand) many similar looking methods or (even) trying to automate the process of code-writing, it sometimes is a hint that there might be a more elegant way to accomplish the goal.

---

<div class="post-metadata">

**Author:** ![Antonio\_Rinaldi](https://forum.xojo.com/user_avatar/forum.xojo.com/antonio_rinaldi/32/331_2.png) [@Antonio\_Rinaldi](https://forum.xojo.com/u/Antonio_Rinaldi)\
**Post date:** [July 19, 2015, 5:44pm UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/14 "2015-07-19T17:44:54Z")

</div>

Oliver, you have to select the right project item before call the new property/method  
For example you want to add it to Window1:

```auto
 if SelectProjectItem("Window1") then
    DoCommand("NewProperty")
    ChangeDeclaration("UserName", "Bob Roberts","String", 2, "")
end if
```

What’s wrong is that this operation take some time and the navigator needs to be updated. Only then you can call this functionality again (I.E: if you call in strict sequence then only the first will be completed and the second call will be ignored.)

---

<div class="post-metadata">

**Author:** ![Oliver\_Scott-Brown](https://forum.xojo.com/letter_avatar_proxy/v4/letter/o/8baadc/32.png) [@Oliver\_Scott-Brown](https://forum.xojo.com/u/Oliver_Scott-Brown)\
**Post date:** [July 19, 2015, 8:46pm UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/15 "2015-07-19T20:46:19Z")

</div>

[quote=201390:@Antonio Rinaldi]Oliver, you have to select the right project item before call the new property/method  
For example you want to add it to Window1:

```auto
 if SelectProjectItem("Window1") then
    DoCommand("NewProperty")
    ChangeDeclaration("UserName", "Bob Roberts","String", 2, "")
end if
```

What’s wrong is that this operation take some time and the navigator needs to be updated. Only then you can call this functionality again (I.E: if you call in strict sequence then only the first will be completed and the second call will be ignored.)[/quote]  
Creating a new property was not the problem. As for the delay, which makes it ignored how do I prevent this?

Thanks

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [July 19, 2015, 11:41pm UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/16 "2015-07-19T23:41:26Z")

</div>

You dont.  
IDE script is basically automating things you could do by hand.  
You do them “slowly” and the IDE can easily keep up.  
A program does them so fast that any minor delays will cause a script issues.

It why I ask what it is people are using it for to get a better handle on what we should do in the future.

---

<div class="post-metadata">

**Author:** ![Antonio\_Rinaldi](https://forum.xojo.com/user_avatar/forum.xojo.com/antonio_rinaldi/32/331_2.png) [@Antonio\_Rinaldi](https://forum.xojo.com/u/Antonio_Rinaldi)\
**Post date:** [July 20, 2015, 7:26am UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/17 "2015-07-20T07:26:47Z")

</div>

After some test it is clear that is not a delay problem but an intrinsic bug for changeDeclaration when you use it for methods.

You can use it for property without problems (any number of properties)  
You can use it for methods only if it is the first changeDeclaration for the project.  
Any further call for method (after properties or as second call for method or with a new script after the first one has failed) will result a no op.

---

<div class="post-metadata">

**Author:** ![Eric\_Brown2](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ad7895/32.png) [@Eric\_Brown2](https://forum.xojo.com/u/Eric_Brown2)\
**Post date:** [July 20, 2015, 9:25am UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/18 "2015-07-20T09:25:47Z")

</div>

[quote=201454:@Antonio Rinaldi]After some test it is clear that is not a delay problem but an intrinsic bug for changeDeclaration when you use it for methods.

You can use it for property without problems (any number of properties)  
You can use it for methods only if it is the first changeDeclaration for the project.  
Any further call for method (after properties or as second call for method or with a new script after the first one has failed) will result a no op.[/quote]

Yup, this is definitely a bug… and as such, a feedback should be created.

---

<div class="post-metadata">

**Author:** ![Eric\_Brown2](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ad7895/32.png) [@Eric\_Brown2](https://forum.xojo.com/u/Eric_Brown2)\
**Post date:** [July 20, 2015, 9:27am UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/19 "2015-07-20T09:27:32Z")

</div>

[quote=201407:@Norman Palardy]You dont.  
IDE script is basically automating things you could do by hand.  
You do them “slowly” and the IDE can easily keep up.  
A program does them so fast that any minor delays will cause a script issues.

It why I ask what it is people are using it for to get a better handle on what we should do in the future.[/quote]

I understand this… and the more I use it, the more I see the current limitations; however, this feature has SO MUCH potential to be extremely powerful and rewarding with so many possibilities. Perhaps something to look closer into in the future.

---

<div class="post-metadata">

**Author:** ![JMichaelTX](https://forum.xojo.com/user_avatar/forum.xojo.com/jmichaeltx/32/509_2.png) [@JMichaelTX](https://forum.xojo.com/u/JMichaelTX)\
**Post date:** [June 16, 2020, 1:06am UTC](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086/20 "2020-06-16T01:06:30Z")

</div>

> [@201454:@Antonio Rinaldi](#):
>
> After some test it is clear that is not a delay problem but an intrinsic bug for changeDeclaration when you use it for methods.

Looks like as of Xojo 19.3.1.47524 (19.3.1.3.47524) on macOS 10.14.6 (Mojave) that bug is fixed.  
Just developed and tested this, and it works.

[h]Create Class and Method from IDE Script[/h]

```auto
Var LF As String = Chr(10)

// --- Create and Select a New Class ---
DoCommand "NewClass"
PropertyValue("Class1.Name") = "MyClass2"

If SelectProjectItem("MyClass2") Then
  DoCommand("NewMethod")
  ChangeDeclaration("IsPointValid", "x As Integer, y As Integer", "Boolean", 2, "")
End If

//--- Method is Now Open for Entry/Edit in the IDE ---

//--- Compose the Method Text ---
Var methodStr As String
methodStr = "" _
+ LF + "//--- Added from IDE Script ---" _
+ LF _
+ LF + "Var z As Boolean" _
+ LF + "z = (x > y)" _
+ LF + "Return z"

//--- Set the Method Text in the IDE ---
Text = methodStr
```

![](https://www.dropbox.com/s/f3zmnd708axly42/Create-Class-and-Method-from-Script.png?raw=1)

[Next page](https://forum.xojo.com/t/ide-scripts-do-not-seem-to-change-declarations-for-methods/25086.md?page=2)
