|
ds_NewMethod |
|---|
| ds_NewMethod (newMethodName {; ID}) <- errorCode | |||
|---|---|---|---|
| Parameter | Type | Description | |
| -> | newMethodName | String | Name of the new method |
| -> | ID | Integer | Method ID |
| <- | errorCode | Long Integer | Error Code (0 = no error) |
Creates a new method named newMethodName.
ID is the ID of the newly created method. Pass 0 or -1 to force 4D to calculate a unique ID for you. If you pass another value, 4D will use this value as ID for the method. If the ID is already used by another method, an error is returned.
IMPORTANT NOTICE: Actual versions of 4D (67/68) don't enable a plugin to inform 4D that a new method has been created: It is important to reload 4D after having created a method this way. What can be done is to create several methods, then quit. Don't change the code of a method if the new code includes names of newly created method, the tokenization will not recognize the new methods.
The following code creates 50 methods named "aMethod_01" to "aMethod_50". Each method will contain a comment saying that it was created using DynamicStructure:
| Sample Code |
|---|
| ` Create_50_Methods |
| C_LONGINT($i;$err;$id) |
| C_TEXT($prefix;$code;$name) |
| $i:=0 |
| $prefix:="aMethod_" |
| $code:="` Created using ds_NewMethod, "+String(Current date) |
| $code:=$code+" - "+String(Current time;HH MM )+"`"+("-"*50) |
| For ($i;1;50) |
| $name:=$prefix+String($i;"00") |
| $id:=-1 |
| $err:=ds_NewMethod ($name;$id) |
| If ($err#0) |
| ALERT("New method #"+String($i)+" => error #"+String($err)) |
| $i:=50 |
| Else |
| $err:=ds_TextToMethod ("` "+$name+$code;$id) |
| If ($err#0) |
| ALERT("ds_TextToMethod#"+String($i)+" => error #"+String($err)) |
| $i:=50 |
| End if |
| End if |
| End for |
| ` |
| QUIT 4D |