メインコンテンツまでスキップ
バージョン:25.4

delete

Command

Delete chunkExpr – to delete a specific chunk or range of text, or items from a list.

Examples:

delete chars 3 to 7 of address
delete item 9 of namesList
delete the last character of line 1 of description

Delete Byte Chunk

The delete command can also be used to delete a byte chunk from within a binary data value. This will reduce the overall size of the data by the number of bytes that are deleted.

Examples:

delete byte 5 of myData
delete the last 2 bytes of myData
delete bytes 100 to 199 of myData

Delete Specific Text or Pattern

Examples:

delete "abc" from codes
delete the first 3 occurrences of <"$",max digits> in text
delete every comma within customerRecord

Delete Items by Value (Added in SenseTalk 2.04)

You can delete items by value, rather than by their position. This is done using an each expression, which can be used to delete items in a list or any text chunk type (lines, words, items, or characters). A where, which, or whose clause selects the specific values to be deleted.

Examples:

delete each item of scores which is less than or equal to zero
delete each line of file "entries" which is empty
delete each item of subscriberList whose expirationDate is earlier than yesterday

Delete a Property from a Property List

Examples:

set dress to {color:"blue", pattern:"gingham", price:$85, size:"small"}
delete dress.price
put dress —> {color:"blue", pattern:"gingham", size:"small"}

Delete Node from a Tree

Examples:

    delete node "product/description" of order

Delete Reference

When a variable is set as a reference to a chunk of another value, the delete command can be used to directly delete that chunk.

Examples:

set numbers to [1,2,3,4,5,6,7,8]
repeat with each num in numbers by reference
if num is an odd number then delete num
end repeat
put numbers —> [2,4,6,8]
  • delete file, delete folder, delete records, delete variable