RemoveProperty

Beschreibung:

Entfernt die anhand des Index oder anhand des Schlüssels spezifizierte Property. Beachten Sie, dass durch das Entfernen einer Property die 0-basierten Indices etwaiger nachfolgender Properties dekrementiert werden (siehe Beispiele).

Parameter:

Parametername

Typ

Beschreibung

Index bzw. Key

Variant

Der identifizierende 0-basierte Index (falls Argumenttyp = Long) der Property, ansonsten der identifizierende Schlüssel (falls Argumenttyp = String) der Property.

Rückgabewert:

Bool

Wert

Beschreibung

True

Entfernen erfolgreich

False

Entfernen nicht erfolgreich

Beispiel VBScript:

Dim oScriptContext : Set oScriptContext = cRM.CurrentProject.CreateScriptContext()

 

oScriptContext.SetProperty "prop0_key", "prop0_value"

MsgBox oScriptContext.GetPropertyKey(0) & " : " & oScriptContext.GetProperty("prop0_key", "prop0_default")

MsgBox oScriptContext.GetPropertyKey(0) & " : " & oScriptContext.GetProperty(0, "prop0_default")

 

oScriptContext.SetProperty "prop1_key", 123

MsgBox oScriptContext.GetPropertyKey(1) & " : " & oScriptContext.GetProperty("prop1_key", "prop1_default")

MsgBox oScriptContext.GetPropertyKey(1) & " : " & oScriptContext.GetProperty(1, "prop1_default")

'Dim deleted : deleted = oScriptContext.RemoveProperty("prop0_key")

Dim deleted : deleted = oScriptContext.RemoveProperty(0)

MsgBox "deleted: " & deleted

MsgBox oScriptContext.GetPropertyKey(0) & " : " & oScriptContext.GetProperty("prop1_key", "prop1_default")

MsgBox oScriptContext.GetPropertyKey(0) & " : " & oScriptContext.GetProperty(0, "prop1_default")

Beispiel C#-Script:

var scriptContext = cRM.CurrentProject.CreateScriptContext();

 

scriptContext.SetProperty("prop0_key", "prop0_value");

MessageBox.Show(scriptContext.GetPropertyKey(0) + " : " + scriptContext.GetProperty("prop0_key", "prop0_default"));

MessageBox.Show(scriptContext.GetPropertyKey(0) + " : " + scriptContext.GetProperty(0, "prop0_default"));

   

scriptContext.SetProperty("prop1_key", 123);

MessageBox.Show(scriptContext.GetPropertyKey(1) + " : " + scriptContext.GetProperty("prop1_key", "prop1_default"));

MessageBox.Show(scriptContext.GetPropertyKey(1) + " : " + scriptContext.GetProperty(1, "prop1_default"));

   

// bool deleted = scriptContext.RemoveProperty("prop0_key");

bool deleted = scriptContext.RemoveProperty(0);

if(deleted)   { MessageBox.Show("property gelöscht!"); }

MessageBox.Show(scriptContext.GetPropertyKey(0) + " : " + scriptContext.GetProperty("prop1_key", "prop1_default"));

MessageBox.Show(scriptContext.GetPropertyKey(0) + " : " + scriptContext.GetProperty(0, "prop1_default"));            

   

scriptContext.Dispose();