Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[VxE]'s := guide ? ( to the ternary ) : ( operator ) .


  • Please log in to reply
17 replies to this topic
TLM
  • Moderators
  • 3821 posts
  • Last active: Nov 11 2014 07:38 PM
  • Joined: 21 Aug 2006
VxE, I got one for ya. How to combine these 2 tern lines into one mate..
txtFileDate = 1/2/2010
  stringSplit, dateArr, txtFileDate, /
    [color=brown]dateArr1 := (strLen(dateArr1) < 2) ? "0" dateArr1 : dateArr1, dateArr2 := (strLen(dateArr2) < 2) ? "0" dateArr2 : dateArr2[/color]
  newDate := dateArr1 . "/" . dateArr2 . "/" . subStr(dateArr3, strLen(dateArr3) -1, strLen(dateArr3))
msgbox % "Original date: " txtFileDate "`nNew Date:      " newDate

In this example the 2nd tern does not eval if the 1st tern is true:
txtFileDate = 1/22/2010
  stringSplit, dateArr, txtFileDate, /
    ; dateArr1 := (strLen(dateArr1) < 2) ? "0" dateArr1 : dateArr1, dateArr2 := (strLen(dateArr2) < 2) ? "0" dateArr2 : dateArr2
  newDate := dateArr1 := (strLen(dateArr1) < 2) ? "0" dateArr1 : dateArr1 . "/" . dateArr2 := (strLen(dateArr2) < 2) ? "0" dateArr2 : dateArr2 . "/" . subStr(dateArr3, strLen(dateArr3) -1, strLen(dateArr3))
msgbox % "Original date: " txtFileDate "`nNew Date:      " newDate
Or does it have to be done separatly??

Thanks again.

MasterFocus
  • Moderators
  • 4322 posts
  • Last active:
  • Joined: 08 Apr 2009

How to combine these 2 tern lines into one

Two simple substitutions seem to solve it.
txtFileDate = 1/2/2010
  stringSplit, dateArr, txtFileDate, /
  newDate := [color=red]( dateArr1 := (strLen(dateArr1) < 2) ? "0" dateArr1 : dateArr1 )[/color] . "/" . [color=darkred]( dateArr2 := (strLen(dateArr2) < 2) ? "0" dateArr2 : dateArr2 )[/color] . "/" . subStr(dateArr3, strLen(dateArr3) -1, strLen(dateArr3))
msgbox % "Original date: " txtFileDate "`nNew Date:      " newDate


TLM
  • Moderators
  • 3821 posts
  • Last active: Nov 11 2014 07:38 PM
  • Joined: 21 Aug 2006
Posted ImageThanks MasterFocus!