PDA

View Full Version : Can we have "Go To Definition" for commands, please?



Ola Eldoy
27-Sep-2010, 05:54 AM
I would really like to be able to go to a command definition from the right click menu in the Studio editor. Probably, this should not include "native" commands from DAW.

Dennis Piccioni
27-Sep-2010, 08:06 AM
I'm pretty sure we discussed this during design of this feature and decided not to do this because writing custom commands isn't supported or encouraged. I am guessing (yep, just a guess) that not too many people use this.

Michael Mullan
27-Sep-2010, 08:25 AM
I do.

There are a whole bunch of places where a simple command can replace many lines of code, and make the resulting code MUCH easier to read.

With a "go to definition" then the "Official reason for non support" "it makes the code too confusing for later maintenance" iirc is made entirely moot.

Michael.

Dennis Piccioni
27-Sep-2010, 09:13 AM
Hi Michael,

the reason for not supporting custom commands has nothing to do with maintenance, it's that we have not supported icode (the command coding language) for at least 15 years (as long as I've been at DAC).

Michael Mullan
27-Sep-2010, 10:33 AM
And how many of the Developers on here have been using df/VDF since before then?

:-)

Seriously though, even without "supporting iCode" is it technically possible to get the studio to do this? Is it something that has to wait until the next code Editor control is chosen?

Doesen't Apple own the trademark on iCode?

Dennis Piccioni
27-Sep-2010, 10:53 AM
I'm not saying it isn't a valid suggestion, I'm just telling why it wasn't implemented when we designed the new Studio.

Rafael M Heise
27-Sep-2010, 01:31 PM
I understood your point Michael, but I disagree this part: "can replace many lines of code". Actually when you create a new command, the command is replaced by all code in #COMMAND, changing all parameters.
So, if you create a command with 10 lines, and you use this command in your code 10 times, you will have 100 lines. I don't like commands so much because I can't debug these commands, and because I really belive you can do almost everything with functions and objects. Of course, there are some situations you will need to create a command. I already created some commands, and it can be very useful.

And I would appreciate if I could do a right click over a command and see the command definition using "Go to definition".

Michael Mullan
27-Sep-2010, 02:32 PM
Commands mean TYPING less code, and make the result easier to read, I really don't care any more about how big my programs are, with the available processors & memory today the little optimizations of cutting out a few dozen lines of code are just not worth the effort.

I sometimes use commands to declare objects or procedures in code, and set default parameters in a single line. There is actually a (minimal) optimization in this, because the re-definition is done at compile time, not runtime.



#COMMAND LinkTriState

Procedure Update_Tristates
String sValue
Get Field_Current_Value of !1 Field !2 to sValue
Set CurrentStatusStr to sValue
End_Procedure
//Fires whenever the value of the control is changed
Procedure OnChange
String sStatus
Get CurrentStatusStr to sStatus
Set Field_Changed_Value of !1 Field !2 to sStatus
End_Procedure

#ENDCOMMAND

then later in a view.

Object oPATIENT_PPA is a cTristateBox
LinkTriState oPatient_DD PATIENT.PPA
Set Location to 12 5
Set Size to 10 150
Set Label to "Relationship problems among couples"
End_Object

Object oPATIENT_PPB is a cTriStateBox
LinkTriState oPatient_DD PATIENT.PPB
Set Location to 25 5
Set Size to 10 150
Set Label to "Family problems"
End_Object
And yes, I could have sub-classed the tristatebox to add the procedures, but I'd still need a way to define the relationship to a particular file.field.

Vincent Oorsprong
28-Sep-2010, 12:44 AM
Michael,

Subclassing is the way, commands are _out_. In the specified example your methods should have made use of Data_File and Data_Field which are set with the - supported - Entry_Item statement.

Commands are still needed in some cases where the compiler needs to do some work before the virtual machine can execute but the need is mainly limited to the provided commands in the product. On top of this, codesense does not know about your commands and cannot help you with parameters etc.

I personally had "tons" of macros in the 2.3 era but the OO way let me hardly ever create new commands.

Ola Eldoy
28-Sep-2010, 04:57 AM
The main reason I want the "go to definition" for commands is that this would make it easier for me to get rid of the commands that we currently have in our code.

DaveR
30-Sep-2010, 09:16 AM
I've probably only 2 or 3 commands (though used multiple times) in some 800 programs but they're spread across both DF and VDF sources.

My mistake was not putting them into an include pkg when I first started using them, so Ola's reason would be my justification too.