is there a way to put comma or quote in one item?

Hi,

I having trouble putting any comma or quote in a msg because it recognize it as a seperate item.
I tried these
put "Item 1, Item 2" into msg

put "Item 1" & comma & " Item 2" into msg

For both of them, it recognize the msg as 2 items.

I need it to be 1 item. Is there a way for Eggplan recognize it (comma or quote) as part of a string instead of a tokenizer?

Thanks

Comments

  • EPJoKEPJoK Member
    You can recognize the string as 1 item if you set the default item delimiter to something other than the ',' character.

    set the defaultItemDelimiter to ":"
    
  • Would that effect all my scripts or just the script that I put that code in?
  • JonathanOSXJonathanOSX ForumAdmin admin
    Setting the defaultItemDelimiter would impact everything from that point on in the script run (until you set it back).

    You can set the delimiter just for the scope of an individual line
    put item 2 delimited by ";" of mylist
    
    You can also use the insert...into syntax:
    insert "car" into mylist
    insert "a, thing" into mylist
    insert "dog" into mylist
    
    put item 2 of mylist
    
  • That insert into works, but as soon as the string is passed to another script it becomes 2 items again. Thanks anyways.
  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    Another approach to consider is to specify "list item" rather than "item". You didn't give us an example of how you're using the msg value after you create it, but an important thing to keep in mind is that the word "item" can refer to either a list item or a text item depending on whether the value you're referring to is a list or not.

    So there are actually two other possibilities here. The first is to explicitly request a list item:
    put "Item 1, Item 2" into msg
    put item 1 of msg -- shows "Item 1" (assumes text item)
    put list item 1 of msg -- shows "Item 1, Item 2"
    
    The second way to do this is to force msg to be a list in the first place, rather than just text (this is also what the "insert" command in the previous example achieves):
    put ("Item 1, Item 2" , ) into msg
    put item 1 of msg -- shows "Item 1, Item 2" (assumes list item)
    
    [Note the extra comma inside the parentheses on the first line here. The comma is needed to make it a list rather than merely an expression enclosed in parentheses.]
    Making a list here to begin with may be the preferable way to go, if what you want is a list. Once you have a list, the word "item" will refer to list items, and of course an item in a list can contain any characters you want.
Sign In or Register to comment.