AutoHotkey Community

It is currently May 27th, 2012, 10:43 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: February 10th, 2008, 2:09 pm 
Offline

Joined: May 10th, 2007, 2:52 am
Posts: 194
Location: China/ Canada
Description: For complicated function not in global mode to output/ input variable, or for special technical command ~

Version List
Update Version http://www.autohotkey.com/forum/viewtop ... 579#177579
Original Version (OutputVar) http://www.autohotkey.com/forum/viewtop ... 590#177590
Original Version (InputVar) http://www.autohotkey.com/forum/viewtop ... 569#177569

Code:
InputVar(Var)
{
 global
 ErrorLevel := %Var%
 return ErrorLevel
}

OutputVar(Var, Value)
{
 global
 %Var% := Value
 return Var
}

_________________
Sakurako ^_^


Last edited by Sakurako on February 10th, 2008, 8:23 pm, edited 4 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2008, 2:19 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Cool, but StringSplit can do the same...

Code:
fx("test|done", "StringCheck")
ListVars
MsgBox

fx(s, d, l = "|", m = "") {
   global
   StringSplit, %d%, s, %l%, %m%
}

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2008, 3:27 pm 
Offline

Joined: May 10th, 2007, 2:52 am
Posts: 194
Location: China/ Canada
Probably complicated function not in global mode would be unlikely to do it that way ...

_________________
Sakurako ^_^


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2008, 5:25 pm 
Offline

Joined: May 10th, 2007, 2:52 am
Posts: 194
Location: China/ Canada
Test
Code:
WindowEditCheck(Var = "TextCheck", StrLen0 = "300", StrLen1 = "3000")
{
 WinGet, WindowCheck, List
 Loop %WindowCheck%
 {
  WindowID := WindowCheck%A_Index%
  WinGetTitle, WindowName, ahk_id %WindowID%
  WinGetClass, WindowClass, ahk_id %WindowID%
  StringReplace, WindowClass, WindowClass, :\, #, 1
  WindowClass := RegExReplace(WindowClass, "\s|&|,|\.|-|:|\\", "_")
  StringReplace, WindowName, WindowName, :\, #, 1
  WindowName := RegExReplace(WindowName, "\s|&|,|\.|-|:|\\", "_")
  WinGet, ControlCheck, ControlList, ahk_id %WindowID%
  Loop, Parse, ControlCheck, `n, `r
   If RegExMatch(A_LoopField, "^Edit\d*$")
   {
    ControlGetText, TextCheck, %A_LoopField%, ahk_id %WindowID%
    If TextCheck
    {
     StringReplace, TextCheck, TextCheck, `r`n, |, 1
     Loop
      If (TextCheck = Edit%A_Index%)
       break
      Else if Edit%A_Index% =
      {
       Edit%A_Index% := TextCheck
       Var%A_Index% := "[" Var "]" "[" WindowID "]" A_LoopField "[" WindowName "]"
       ANum := A_Index
       break
      }
    }
   }
 }
 Loop %ANum%
 {
  If (StrLen(Edit%A_Index%) > StrLen0)
   If (StrLen(Edit%A_Index%) < StrLen1)
   {
    OutputVar(Var%A_Index%, Edit%A_Index%)
    VarCheck := Var%A_Index%
    Rec%VarCheck% := Edit%A_Index%
   }
 }
listvars
pause
}

_________________
Sakurako ^_^


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2008, 6:04 pm 
Offline

Joined: May 10th, 2007, 2:52 am
Posts: 194
Location: China/ Canada
Input
Code:
TimeCheck := A_TickCount
Test()

Test()
{
 Test := InputVar("TimeCheck")
 listvars
 pause
}
Code:
InputVar(Var)
{
 global
 ValueCheck := %Var%
 return ValueCheck
}

_________________
Sakurako ^_^


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2008, 6:48 pm 
Offline

Joined: May 10th, 2007, 2:52 am
Posts: 194
Location: China/ Canada
Update
Code:
NumTest = 4
TestS()
listvars
pause
Test()
listvars
return

Test()
{
 OutputVar("NumTest0", "")
 OutputVar("NumTest1", "")
 OutputVar("NumTestS", "")
listvars
pause
 OutputVar("NumTestS", InputVar(OutputVar("NumTest1", InputVar(OutputVar("NumTest0", InputVar("NumTest") + 1)) - 6)) + 4)
}

TestS()
{
 Msgbox, % "NumTest" " " InputVar("NumTest") "`n" "NumTest0" " " InputVar(OutputVar("NumTest0", InputVar("NumTest") + 1)) "`n" "NumTest1" " " InputVar(OutputVar("NumTest1", InputVar("NumTest0") - 6)) "`n" "NumTestS" " " InputVar(OutputVar("NumTestS", InputVar("NumTest1") + 4))
}

Code:
InputVar(Var)
{
 global
 ErrorLevel := %Var%
 return ErrorLevel
}

OutputVar(Var, Value)
{
 global
 %Var% := Value
 return Var
}

_________________
Sakurako ^_^


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2008, 7:29 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Sakurako please post updates on your first post instead of creating numerous new ones.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 10th, 2008, 7:41 pm 
Offline

Joined: May 10th, 2007, 2:52 am
Posts: 194
Location: China/ Canada
Original Version
Sakurako wrote:
Code:
StringTest("test|done", "StringCheck")
listvars
pause

StringTest(String, OutputVar = "TextCheck")
{
 If OutputVar
 {
  StringSplit, %OutputVar%, String, |
  Loop
   If %OutputVar%%A_Index% <>
    OutputVar(OutputVar . A_Index, %OutputVar%%A_Index%)
   Else
    break
  return "done"
 }
 Else
  return "error"
}

OutputVar(Var, Value)
{
 global
 %Var% := Value
}
Code:
OutputVar(Var, Value)
{
 global
 %Var% := Value
}

_________________
Sakurako ^_^


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group