Class ScriptProperties

Script 屬性

已淘汰。這個類別已淘汰,不應在新的指令碼中使用。

指令碼屬性是指令碼在永久儲存區中儲存的鍵/值組合。無論是哪位使用者執行指令碼,每個指令碼的範圍都會是指令碼本身。

方法傳回類型簡短說明
deleteAllProperties()ScriptProperties刪除所有資源。
deleteProperty(key)ScriptProperties刪除指定鍵的屬性。
getKeys()String[]取得所有可用的鍵。
getProperties()Object一次取得所有可用的資源。
getProperty(key)String傳回與提供的鍵相關聯的值,如果沒有此類值,則傳回空值。
setProperties(properties)ScriptProperties從指定物件繪製的所有屬性,以大量方式設定。
setProperties(properties, deleteAllOthers)ScriptProperties從指定物件繪製的所有屬性,以大量方式設定。
setProperty(key, value)ScriptProperties使用提供的鍵,將指定的 in 值儲存起來。

已淘汰的方法

已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

刪除所有資源。

ScriptProperties.deleteAllProperties();

回攻員

ScriptProperties:這個物件,用於鏈結

另請參閱


已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

刪除指定鍵的屬性。

ScriptProperties.deleteProperty('special');

參數

名稱類型說明
keyString要刪除的資源鍵

回攻員

ScriptProperties:這個物件,用於鏈結

另請參閱


已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

取得所有可用的鍵。

回攻員

String[]


已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

一次取得所有可用的資源。

這會提供副本,而非即時檢視畫面,因此變更已回傳物件的屬性不會更新儲存空間中的屬性,反之亦然。

ScriptProperties.setProperties({
  "cow"     : "moo",
  "sheep"   : "baa",
  "chicken" : "cluck"
});

// Logs "A cow goes: moo"
Logger.log("A cow goes: %s", ScriptProperties.getProperty("cow"));

// This makes a copy. Any changes that happen here will not
// be written back to properties.
var animalSounds = ScriptProperties.getProperties();

// Logs:
// A chicken goes cluck!
// A cow goes moo!
// A sheep goes baa!
for(var kind in animalSounds) {
  Logger.log("A %s goes %s!", kind, animalSounds[kind]);
}

回攻員

Object:包含鍵/值組合的屬性副本


已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

傳回與提供的鍵相關聯的值,如果沒有此類值,則傳回空值。

const specialValue = ScriptProperties.getProperty('special');

參數

名稱類型說明
keyString要擷取的值的鍵

回攻員

String:與鍵相關聯的值

另請參閱


已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

大量設定從指定物件繪製的所有屬性。

ScriptProperties.setProperties({special: 'sauce', 'meaning': 42});

參數

名稱類型說明
propertiesObject包含要設定的屬性的物件。

回攻員

ScriptProperties:這個物件,用於鏈結

另請參閱


已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

大量設定從指定物件繪製的所有屬性。

// This deletes all other properties
ScriptProperties.setProperties({special: 'sauce', 'meaning': 42}, true);

參數

名稱類型說明
propertiesObject包含要設定的屬性的物件。
deleteAllOthersBoolean是否要刪除所有現有資源。

回攻員

ScriptProperties:這個物件,用於鏈結

另請參閱


已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

使用提供的鍵將指定的值儲存。系統會覆寫與此鍵相關聯的任何現有值。

ScriptProperties.setProperty('special', 'sauce');

參數

名稱類型說明
keyString屬性鍵
valueString要與鍵建立關聯的值

回攻員

ScriptProperties:這個物件,用於鏈結

另請參閱