AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GuiControl cutting off after space [solved]

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
System Monitor



Joined: 09 Mar 2007
Posts: 509
Location: Unknown

PostPosted: Thu Feb 18, 2010 6:40 am    Post subject: GuiControl cutting off after space [solved] Reply with quote

When using GuiControl to change the text of a text control it cuts off the remaining text in the variable after the space. I have no idea why it would do this!!! I put a message box to check that the variable does have more content. I have highlighted the line that is the problem in red.

Code:
#SingleInstance force
SetTimer, Second, 1000

list := "Period x,10:20 PM, 11:00 PM"

Gui, Add, ListBox, x4 y92 w464 h164 , ListBox
Gui, Add, MonthCal, x123 y259 w228 h163 ,
gui, font,s20, Verdana ;add cwhite
Gui, Add, Text, x3 y4 w466 h43 vTime , Time:
Gui, Add, Text, x7 y55 w461 h30 vTimeLeft, Time Left in xth Period:
FormatTime, timenow, , h:mm:ss tt
GuiControl,,Time, Time: %timenow%

Gui, Show, x360 y162 h517 w546, Time
Return

GuiClose:
ExitApp

Second:
FormatTime, timenow, , h:mm:ss tt
current := CurrentPeriod(list)
GuiControl,,TimeLeft, %current%
GuiControl,,Time, Time: %timenow%
return


FormatSeconds(NumberOfSeconds)  ; Convert the specified number of seconds to hh:mm:ss format.
{
    time = 19990101  ; *Midnight* of an arbitrary date.
    time += %NumberOfSeconds%, seconds
    FormatTime, mmss, %time%, mm:ss
    return NumberOfSeconds//3600 ":" mmss  ; This method is used to support more than 24 hours worth of sections.
}

; example file: 1st,8:00 AM,8:50 PM
CurrentPeriod(list)
{
   loop, parse, list, `n
   {
      loop, parse, A_LoopField, `,
      {
      if A_Index = 1
      {
         name := A_LoopField
      }
      if A_Index = 2
         begin := DateParse(A_LoopField)
      if A_Index = 3
         end := DateParse(A_LoopField)
      }
      if begin <= A_Now and end >= A_Now
         return name . "`," . begin . "`," . end
   }
   return
}

DateParse(str) {
   static e2 = "i)(?:(\d{1,2}+)[\s\.\-\/,]+)?(\d{1,2}|(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\w*)[\s\.\-\/,]+(\d{2,4})"
   str := RegExReplace(str, "((?:" . SubStr(e2, 42, 47) . ")\w*)(\s*)(\d{1,2})\b", "$3$2$1", "", 1)
   If RegExMatch(str, "i)^\s*(?:(\d{4})([\s\-:\/])(\d{1,2})\2(\d{1,2}))?"
      . "(?:\s*[T\s](\d{1,2})([\s\-:\/])(\d{1,2})(?:\6(\d{1,2})\s*(?:(Z)|(\+|\-)?"
      . "(\d{1,2})\6(\d{1,2})(?:\6(\d{1,2}))?)?)?)?\s*$", i)
      d3 := i1, d2 := i3, d1 := i4, t1 := i5, t2 := i7, t3 := i8
   Else If !RegExMatch(str, "^\W*(\d{1,2}+)(\d{2})\W*$", t)
      RegExMatch(str, "i)(\d{1,2})\s*:\s*(\d{1,2})(?:\s*(\d{1,2}))?(?:\s*([ap]m))?", t)
         , RegExMatch(str, e2, d)
   f = %A_FormatFloat%
   SetFormat, Float, 02.0
   d := (d3 ? (StrLen(d3) = 2 ? 20 : "") . d3 : A_YYYY)
      . ((d2 := d2 + 0 ? d2 : (InStr(e2, SubStr(d2, 1, 3)) - 40) // 4 + 1.0) > 0
         ? d2 + 0.0 : A_MM). ((d1 += 0.0) ? d1 : A_DD) . t1
         + (t1 = 12 ? t4 = "am" ? -12.0 : 0.0 : t4 = "am" ? 0.0 : 12.0) . t2 + 0.0 . t3 + 0.0
   SetFormat, Float, %f%
   Return, d
}

Time(to,from="",units="",params=""){
   static _:="0000000000",s:=1,m:=60,h:=3600,d:=86400
            ,Jan:="01",Feb:="02",Mar:="03",Apr:="04",May:="05",Jun:="06",Jul:="07",Aug:="08",Sep:="09",Okt:=10,Nov:=11,Dec:=12
   r:=0
   units:=units ? %units% : 8640
   If (InStr(to,"/") or InStr(to,"-") or InStr(to,".")){
      Loop,Parse,to,/-.,%A_Space%
         _%A_Index%:=RegExMatch(A_LoopField,"\d+") ? A_LoopField : %A_LoopField%
         ,_%A_Index%:=(StrLen(_%A_Index%)=1 ? "0" : "") . _%A_Index%
      to:=SubStr(A_Now,1,8-StrLen(_1 . _2 . _3)) . _3 . (RegExMatch(SubStr(to,1,1),"\d") ? (_2 . _1) : (_1 . _2))
      _1:="",_2:="",_3:=""
   }
   If (from and InStr(from,"/") or InStr(from,"-") or InStr(from,".")){
      Loop,Parse,from,/-.,%A_Space%
         _%A_Index%:=RegExMatch(A_LoopField,"\d+") ? A_LoopField : %A_LoopField%
         ,_%A_Index%:=(StrLen(_%A_Index%)=1 ? "0" : "") . _%A_Index%
      from:=SubStr(A_Now,1,8-StrLen(_1 . _2 . _3)) . _3 . (RegExMatch(SubStr(from,1,1),"\d") ? (_2 . _1) : (_1 . _2))
   }
   count:=StrLen(to)<9 ? "days" : StrLen(to)<11 ? "hours" : StrLen(to)<13 ? "minutes" : "seconds"
   to.=SubStr(_,1,14-StrLen(to)),(from ? from.=SubStr(_,1,14-StrLen(from)))
   Loop,Parse,params,%A_Space%
      If (unit:=SubStr(A_LoopField,1,1))
          %unit%1:=InStr(A_LoopField,"-") ? SubStr(A_LoopField,2,InStr(A_LoopField,"-")-2) : ""
         ,%unit%2:=SubStr(A_LoopField,InStr(A_LoopField,"-") ? (InStr(A_LoopField,"-")+1) : 2)
   count:=!params ? count : "seconds"
   add:=!params ? 1 : (S2="" ? (M2="" ? (H2="" ? ((D2="" and B2="" and W="") ? d : h) : m) : s) : s)
   While % (from<to){
      FormatTime,year,%from%,YYYY
      FormatTime,month,%from%,MM
      FormatTime,day,%from%,dd
      FormatTime,hour,%from%,H
      FormatTime,minute,%from%,m
      FormatTime,second,%from%,s
      FormatTime,WDay,%from%,WDay
      EnvAdd,from,%add%,%count%
      If (W1 or W2){
         If (W1=""){
            If (W2=WDay or InStr(W2,"." . WDay) or InStr(W2,WDay . ".")){
               Continue=1
            }
         } else If WDay not Between %W1% and %W2%
            Continue=1
         ;else if (Wday=W2)
         ;   Continue=1
         If (Continue){
            ErrorLevel:=SubStr(from,1,8)
            EnvAdd,ErrorLevel,1,days
            EnvSub,ErrorLevel,%from%,seconds
            EnvAdd,from,%ErrorLevel% ,seconds
            Continue=
            continue
         }
      }
      If (D1 or D2 or B2){
         If (D1=""){
            If (D2=day or B2=(day . month) or InStr(B2,"." . day . month) or InStr(B2,day . month . ".") or InStr(D2,"." . day) or InStr(D2,day . ".")){
               Continue=1
            }
         } else If day not Between %D1% and %D2%
            Continue=1
         ;else if (day=D2)
         ;   Continue=1
         If (Continue){
            ErrorLevel:=SubStr(from,1,8)
            EnvAdd,ErrorLevel,1,days
            EnvSub,ErrorLevel,%from%,seconds
            EnvAdd,from,%ErrorLevel% ,seconds
            Continue=
            continue
         }
      }
      If (H1 or H2){
         If (H1=""){
            If (H2=hour or InStr(H2,hour . ".") or InStr(H2,"." hour)){
               Continue=1
            }
         } else If hour not Between %H1% and %H2%
            continue=1
         ;else if (hour=H2)
         ;   continue=1
         If (continue){
            ErrorLevel:=SubStr(from,1,10)
            EnvAdd,ErrorLevel,1,hours
            EnvSub,ErrorLevel,%from%,seconds
            EnvAdd,from,%ErrorLevel% ,seconds
            continue=
            continue
         }
      }
      If (M1 or M2){
         If (M1=""){
            If (M2=minute or InStr(M2,minute . ".") or InStr(M2,"." minute)){
               Continue=1
            }
         } else If minute not Between %M1% and %M2%
            continue=1
         ;else if (minute=M2)
         ;   continue=1
         If (continue){
            ErrorLevel:=SubStr(from,1,12)
            EnvAdd,ErrorLevel,1,minutes
            EnvSub,ErrorLevel,%from%,seconds
            EnvAdd,from,%ErrorLevel% ,seconds
            continue=
            continue
         }
      }
      If (S1 or S2){
         If (S1=""){
            If (S2=second or InStr(S2,second . ".") or InStr(S2,"." second)){
               Continue
            }
         } else if (second!=S2)
            If second not Between %S1% and %S2%
               continue
      }
      r+=add
   }
   ErrorLevel:=SubStr(count,1,1)
   ErrorLevel:=%ErrorLevel%
   Return (r*ErrorLevel)/units
}


Thanks Very Happy


Last edited by System Monitor on Fri Feb 19, 2010 1:34 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Thu Feb 18, 2010 7:03 am    Post subject: Re: GuiControl cutting off after space Reply with quote

Without testing...it's probably wrapping after the space, increase the controls width...
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group