 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
madhatr
Joined: 10 Jan 2007 Posts: 33
|
Posted: Sat May 05, 2007 12:38 am Post subject: Input field breakdown |
|
|
I'm sorry but I don't even know where to start searching for the help on a script I am writting.
I have a line of numbers and letters that would be entered in by a user and each one of the numbers or letters repressents something. It is similar to a VIN number on a car. The first 3 letters of the code would repressent a model and then each one of the numbers or letters after that would repressent options for that model.
How would I go about breaking down the information that is entered so that I could then display what the code means?
Example:
User Enters: ABC15502
Output of: Ford Mustang GT V8 Convertable Manual Red
In this case:
ABC = Ford
1 = GT
5 = V8
etc...
Depending on what the first 3 digits are changes what the results for the rest are. 5 only equals "V8" on a ABC, if the user had enter EFG then that same 5 would equal V6 and so on.
Any help or just a point in the right direction would be much appreciated. Thanks in advance |
|
| Back to top |
|
 |
POINTS after work Guest
|
Posted: Sat May 05, 2007 1:44 am Post subject: Substring |
|
|
You can use the substring command to split what the user enters. http://www.autohotkey.com/docs/Functions.htm#SubStr
| AHK Help wrote: | | SubStr(String, StartingPos [, Length]) [v1.0.46+]: Copies a substring from String starting at StartingPos and proceeding rightward to include at most Length characters (if Length is omitted, it defaults to "all characters"). For StartingPos, specify 1 to start at the first character, 2 to start at the second, and so on (if StartingPos is beyond String's length, an empty string is returned). If StartingPos is less than 1, it is considered to be an offset from the end of the string. For example, 0 extracts the last character and -1 extracts the two last characters (but if StartingPos tries to go beyond the left end of the string, the extraction starts at the first character). Length is the maximum number of characters to retrieve (fewer than the maximum are retrieved whenever the remaining part of the string too short). Specify a negative Length to omit that many characters from the end of the returned string (an empty string is returned if all or too many characters are omitted). Related items: RegExMatch(), StringMid, StringLeft/Right, StringTrimLeft/Right. |
You could do a bunch of if else statements or make your substrings reference the info (second way is much better).
This one gives me a headache (this method gets a C-):
| Code: | UserString = ABC15502
makestring := SubStr(UserString, 1, 3)
if (makestring = "ABC")
{
Make = Ford Mustang
modelstring := SubStr(UserString, 4, 1)
if (modelstring = "1")
{
Model = GT
}
;etc...
enginestring := SubStr(UserString, 5, 1)
if (enginestring = "5")
{
Engine = V8
}
;etc...
}
else if (makestring = "DEF")
{
Model = "Honda"
}
else
{
Model = "Unknown"
}
Msgbox, %Make% %Model% %Engine% |
*MUCH* nicer (this is so badass I think it's time for beer and deserves an A+++):
| Code: | ; Car look up thinge
; Colors (if all the color codes are the same)
ColorArray0 = Black
ColorArray1 = White
ColorArray2 = Red
ColorArray3 = Orange
ColorArray4 = Yellow
ColorArray5 = Green
ColorArray6 = Light Green, Black, and Orange Stripes
; Car look up thinge
; ABC: Ford Mustang
ABCModelArray1 = GT
ABCModelArray2 = GTX
ABCModelArray3 = GTXL
ABCModelArray4 = FireBird
ABCEngineArray1 = I3 1.0
ABCEngineArray2 = I4 1.3
ABCEngineArray3 = V6 3.0
ABCEngineArray4 = V6 3.2
ABCEngineArray5 = V8
ABCOptionArray1 = Sun Roof
ABCOptionArray2 = 4 Door
ABCOptionArray3 = 2 Door
ABCOptionArray4 = Hatchback
ABCOptionArray5 = Convertable
ABCTransArray0 = Manual
ABCTransArray1 = Automatic
; DEF = Toyota Van
DEFModelArray1 = Van
DEFModelArray2 = Van XL
DEFEngineArray1 = I4
DEFEngineArray2 = V6
; Make and Model Codes
ABC = Ford Mustang
DEF = Toyota Van
; Later add a GUI to have the user type this in or select options from drop down menus
UserString = ABC15502
; Yeah, all that if else statements is just a few lines now
MakeCode := SubStr(UserString, 1, 3)
; Make
Make := %MakeCode%
; Model
Temp := SubStr(UserString, 4, 1)
Model := %MakeCode%ModelArray%Temp%
; Engine
Temp := SubStr(UserString, 5, 1)
Engine := %MakeCode%EngineArray%Temp%
; Options
Temp := SubStr(UserString, 6, 1)
Options := %MakeCode%OptionsArray%Temp%
; Tranny
Temp := SubStr(UserString, 7, 1)
Trans := %MakeCode%TransArray%Temp%
; Color
Temp := SubStr(UserString, 8, 1)
Color := ColorArray%Temp%
Msgbox, %Make% %Model% %Engine% %Options% %Trans% %Color% |
The second way is much cleaner and it keeps your data separate from your code, making it much easier to maintain as well as add and delete things.
This only a start. You could arrange the arrays differently so they could be added to drop down lists or even store the data in a separate text file that would be read in when the program starts. |
|
| Back to top |
|
 |
madhatr
Joined: 10 Jan 2007 Posts: 33
|
Posted: Sun May 06, 2007 4:31 pm Post subject: Works GREAT |
|
|
I went with the second method (tried the first one and it got messy very fast) and I would give it a A++++++. It is working wonderfully. The only problem I am having with that method is if a incorrect number is entered then it gives a Error: This dynamic variable is blank.
In other words the user typed in a 6 but there is only a option 1,2,4 and A for that model so it does not have a label to point to.
What would be the best way to redirect this to a message box stating "Not a valid number". I know I could do some kind of if does not equal, but then I would have to do that for every combination and I know there has to be a better way. |
|
| Back to top |
|
 |
POINTS about togoto lunch Guest
|
Posted: Mon May 07, 2007 7:40 pm Post subject: code |
|
|
Could you post the code that you have so far?
I think the best way would be to limit the user's input. |
|
| Back to top |
|
 |
madhatr
Joined: 10 Jan 2007 Posts: 33
|
Posted: Tue May 08, 2007 2:03 am Post subject: |
|
|
| Code: | ;Gui
Gui, Add, GroupBox, x5 y0 w390 h225 ,
Gui, Add, Text, x15 y15, 16 Digit Configuration Number
Gui, Add, Edit, x15 y35 w110 r1 Limit16 vConfigNumber,
Gui, Add, Button, x135 y35 w60 h20 gSubmit , Submit
Gui, Add, Button, x330 y200 w60 h20 gClear , Clear
Gui, Show, x131 y91 h230 w400, Config Reader
Return
Submit:
Gui, Submit, NoHide
UserString = %ConfigNumber%
Modelcode := SubStr(UserString, 2, 2)
Model := %Modelcode%
Temp := SubStr(UserString, 4, 1)
Field04 := %Modelcode%_F04_%Temp%
Temp := SubStr(UserString, 5, 1)
Field05 := %Modelcode%_F05_%Temp%
Temp := SubStr(UserString, 6, 1)
Field06 := %Modelcode%_F06_%Temp%
Temp := SubStr(UserString, 7, 1)
Field07 := %Modelcode%_F07_%Temp%
Temp := SubStr(UserString, 8, 1)
Field08 := %Modelcode%_F08_%Temp%
Temp := SubStr(UserString, 9, 1)
Field09 := %Modelcode%_F09_%Temp%
Temp := SubStr(UserString, 10, 1)
Field10 := %Modelcode%_F10_%Temp%
Temp := SubStr(UserString, 11, 1)
Field11 := %Modelcode%_F11_%Temp%
Temp := SubStr(UserString, 12, 1)
Field12 := %Modelcode%_F12_%Temp%
Temp := SubStr(UserString, 13, 1)
Field13 := %Modelcode%_F13_%Temp%
Temp := SubStr(UserString, 14, 1)
Field14 := %Modelcode%_F14_%Temp%
Temp := SubStr(UserString, 15, 1)
Field15 := %Modelcode%_F15_%Temp%
Temp := SubStr(UserString, 16, 1)
Field16 := %Modelcode%_F16_%Temp%
LCD := %Modelcode%_LCD
Gui, Add, Text, x17 y65 r1 , Config Number = %ConfigNumber%
;Model, CPU, OS, War, Bay, Main Mem, Ext Mem, HDD, Com, Point, Keyboard, FDD, Bat, 2nd Bat
If (Model = JA)
{
Gui, Add, Text, x17 y85 r1, Model:
Gui, Add, Text, x70 y85 r1 cBlue, %Model%
Gui, Add, Text, x17 y100 r1, LCD:
Gui, Add, Text, x70 y100 r1 cBlue, %LCD%
Gui, Add, Text, x17 y115 r1, CPU:
Gui, Add, Text, x70 y115 r1 cBlue, %Field04%
Gui, Add, Text, x17 y130 r1, OS:
Gui, Add, Text, x70 y130 r1 cBlue, %Field05%
Gui, Add, Text, x17 y145 r1, Warranty:
Gui, Add, Text, x70 y145 r1 cBlue, %Field06%
Gui, Add, Text, x17 y160 r1, Bay:
Gui, Add, Text, x70 y160 r1 cBlue, %Field07%
Gui, Add, Text, x17 y175 r1, Memory:
EnvAdd, Memadd, 2
Memadd += 2
MemTotal = %Field08%
MemTotal += %Field09%
Mem = %MemTotal%
Gui, Add, Text, x70 y175 r1 cBlue, %MEM% (%Field08%+%Field09%)
Gui, Add, Text, x187 y85 r1, HDD:
Gui, Add, Text, x250 y85 r1 cBlue, %Field10%
Gui, Add, Text, x187 y100 r1, Com:
Gui, Add, Text, x250 y100 r1 cBlue, %Field11%
Gui, Add, Text, x187 y115 r1, Point Dev:
Gui, Add, Text, x250 y115 r1 cBlue, %Field12%
Gui, Add, Text, x187 y130 r1, Keyboard:
Gui, Add, Text, x250 y130 r1 cBlue, %Field13%
Gui, Add, Text, x187 y145 r1, FDD:
Gui, Add, Text, x250 y145 r1 cBlue, %Field14%
Gui, Add, Text, x187 y160 r1, Main Batt:
Gui, Add, Text, x250 y160 r1 cBlue, %Field15%
Gui, Add, Text, x187 y175 r1, 2nd Batt:
Gui, Add, Text, x250 y175 r1 cBlue, %Field16%
Return
}
Return
Clear:
Reload
return
GuiClose:
ExitApp |
The problem is that with each model different numbers or letters are used.
On one model the 4th digit can only be a 6, E or F but on another model that same digit can be a 2, 7 or 9.
I excluded all the var's due to the fact that so far it already about 20k and will end up being much bigger with over 200 models, each with 13 options and each option having up to 6 results. Once I have all that entered in I have to take the results, word-wrap it somehow so it will fit on a label and output it to a label printing program. Just to make it even more difficult not every model has the same pattern for the config, some are CPU, OS, Warranty, while others are CPU, OS, Memory. That is the reason for the "If (Model = JA)" other configs are set up differently so there are many things like "If (Model = BG or Model = BH or Model = BN or Model = BP or Model = BT or Model = BU or Model = BZ or Model = BY)" in it. |
|
| Back to top |
|
 |
POINTS
Joined: 18 Jan 2006 Posts: 284
|
Posted: Thu May 10, 2007 12:34 am Post subject: Hmm |
|
|
This will keep it cleaner (maybe):
| Code: | BG_F08_4 := "VW BUG"
Modelcode = BG
Temp = 5
Field08 := Check(%Modelcode%_F08_%Temp%)
msgbox, Field08 = %Field08%
Temp = 4
Field08 := Check(%Modelcode%_F08_%Temp%)
msgbox, Field08 = %Field08%
Check(strVar)
{
if strVar =
{
msgbox, It's blank!
return "INVALID INPUT"
}
else
return strVar
} |
but you might be better off having an if statement after every item:
| Code: | BG_F08_4 := "VW BUG"
Modelcode = BG
Temp = 5
Field08 := %Modelcode%_F08_%Temp%
if Field08 =
Msgbox, Invalid Input
return ; or do something else when it's invalid |
but that all depends on what you want to do when it's invalid. If it's the same for every item, use a function, otherwise make a lot of if's. _________________ My AutoHotkey Program for Warcraft III:
Warkeys
http://warkeys.sourceforge.net/
Remap your hotkeys
Healthbars always on
Remap inventory |
|
| Back to top |
|
 |
madhatr
Joined: 10 Jan 2007 Posts: 33
|
Posted: Sat May 19, 2007 12:02 am Post subject: |
|
|
Ok, everything is working great. I added
| Code: | StringLen, length, UserString
if length < 16
{
MsgBox, You only typed in %length% digits, 16 are required.
Goto Error
Return
} |
to remove erroring out when not enough numbers are typed. I then added
| Code: | Modelcode := SubStr(UserString, 2, 2)
Model := %Modelcode%
if Model =
{
Msgbox, Invalid Input on digits 1,2 or 3
Goto Error
Return
} |
and that stopped errors when incorrect numbers are typed.
Now what I would love to do is brake up all the data so that the program can pull the information from text files. Something along the lines of 1 text file for each model like JA.txt and that would contain:
JA := "A1010"
JA_F04_0 := "AMD 1.2GHz"
etc...
I know I would end up having a ton of small text files, but it would allow me to change the information easily without having to recompile the program everytime there is a change. How would I go about pulling all the array's from a file like that? |
|
| Back to top |
|
 |
POINTS
Joined: 18 Jan 2006 Posts: 284
|
Posted: Sat May 19, 2007 1:45 am Post subject: Yes, I have finally logged in |
|
|
You can put everything in one text file by creating "titles". Also, you should keep the code out of the text files. Here's what you do:
temp.ahk
| Code: | ; Read from the txt file
count = 1
Loop, Read, temp.txt
{
if (A_LoopReadLine) ; ignore blank lines
{
StringLeft, cFirstChar, A_LoopReadLine, 1
if cFirstChar != `; ; semicolons are comments
{
StringRight, cLastChar, A_LoopReadLine, 1
FoundPos := RegExMatch(A_LoopReadLine, "::")
if (FoundPos) ; if last 2 chars are :'s then it's a new car
{
StringLeft, strCar, A_LoopReadLine, % FoundPos - 1
StringTrimLeft, strCarName, A_LoopReadLine, % FoundPos + 1
%strCar% := strCarName
count = 1
}
else if (cLastChar == ":" ) ; if just one colon then it's a new option
{
StringTrimRight, strOption, A_LoopReadLine, 1
count = 1
}
else ; otherwise put it in an array
{
%strCar%%strOption%Array%count% := A_LoopReadLine
count := count + 1
}
}
}
}
listvars
; Later add a GUI to have the user type this in or select options from drop down menus
UserString = ABC15512
; Yeah, all that if else statements is just a few lines now
MakeCode := SubStr(UserString, 1, 3)
; Make
Make := %MakeCode%
; Model
Temp := SubStr(UserString, 4, 1)
Model := %MakeCode%ModelArray%Temp%
; Engine
Temp := SubStr(UserString, 5, 1)
Engine := %MakeCode%EngineArray%Temp%
; Options
Temp := SubStr(UserString, 6, 1)
Options := %MakeCode%OptionsArray%Temp%
; Tranny
Temp := SubStr(UserString, 7, 1)
Trans := %MakeCode%TransArray%Temp%
; Color
Temp := SubStr(UserString, 8, 1)
Color := ColorArray%Temp%
Msgbox, %Make% %Model% %Engine% %Options% %Trans% %Color% |
temp.txt
| Code: | ; Car look up thinge
; Colors (if all the color codes are the same)
Color:
Black
White
Red
Orange
Yellow
Green
Light Green, Black, and Orange Stripes
; Car look up thinge
ABC::Ford Mustang
Model:
GT
GTX
GTXL
FireBird
Engine:
I3 1.0
I4 1.3
V6 3.0
V6 3.2
V8
Option:
Sun Roof
4 Door
2 Door
Hatchback
Convertable
Trans:
Manual
Automatic
; DEF = Toyota Van
DEF::Toyota Van
Model:
Van
Van XL
Engine:
I4
V6
|
So, lines that begin with a ; are comments (you can change this to something like #), two colons mean a new car, and one colon is a sub-option of the car (followed by a list of variables). _________________ My AutoHotkey Program for Warcraft III:
Warkeys
http://warkeys.sourceforge.net/
Remap your hotkeys
Healthbars always on
Remap inventory |
|
| Back to top |
|
 |
nick
Joined: 24 Aug 2005 Posts: 345 Location: Berlin / Germany
|
Posted: Sat May 19, 2007 10:28 am Post subject: |
|
|
| madhatr wrote: | Now what I would love to do is brake up all the data so that the program can pull the information from text files. Something along the lines of 1 text file for each model like JA.txt and that would contain:
JA := "A1010"
JA_F04_0 := "AMD 1.2GHz"
etc...
I know I would end up having a ton of small text files, but it would allow me to change the information easily without having to recompile the program everytime there is a change. How would I go about pulling all the array's from a file like that? |
I thought about that when first reading your previous posts. I would do the same so I wasn't really unprepared.
Maybe you would like this:
| Code: | #NoEnv
#Persistent
SetBatchLines, -1
CfgDir := A_ScriptDir . "\"
;Gui
Gui, Add, GroupBox, x5 y0 w390 h225 ,
Gui, Add, Text, x15 y15, 16 Digit Configuration Number
Gui, Add, Edit, x15 y35 w110 r1 Limit16 Uppercase vConfigNumber,
Gui, Add, Button, x135 y35 w60 h20 gSubmit , Submit
Gui, Add, Button, x330 y200 w60 h20 gClear , Clear
Gui, Show, x131 y91 h230 w400, Config Reader
Return
GuiClose:
GuiEscape:
Gui, Destroy
ExitApp
Clear:
Reload
Return
Submit:
Gui, Submit, NoHide
UserString = %ConfigNumber%
If (StrLen(UserString) <> 16)
{
MsgBox, 16 Digit Configuration Number, please!
GuiControl, Focus, ConfigNumber
Return
}
Model := SubStr(UserString, 2, 2)
If (!FileExist(CfgDir . Model . ".cfg"))
{
MsgBox, No Config File for Model %Model%
GuiControl, Focus, ConfigNumber
Return
}
FileRead, Config, %CfgDir%%Model%.cfg
If (!RegExMatch(Config, "`aim)^Model=" . Model)) {
MsgBox, Wrong Config File for Model %Model%
GuiControl, Focus, ConfigNumber
Return
}
If (RegExMatch(Config, "`aim)^LCD=(.+)$", RX)) {
LCD := RX1
} Else {
LCD := "Unknown"
}
Temp := SubStr(UserString, 4)
Loop, Parse, Temp
{
If Field_OK(Config, A_LoopField, A_Index)
{
Field%A_Index% := A_LoopField
Match := "`aim)^Value" . A_Index . "_" . A_LoopField . "=(.+)$"
If (RegExMatch(Config, Match, RX)) {
Value%A_Index% := RX1
} Else {
Value%A_Index% := "Unknown"
}
}
Else
{
GuiControl, Focus, ConfigNumber
Pos := A_Index + 3
SendInput, {Home}{Right %Pos%}{Shift Down}{Left}{Shift Up}
Return
}
}
Gui, Add, Text, x17 y65 r1 , Config Number = %ConfigNumber%
Gui, Add, Text, x17 y85 r1, Model:
Gui, Add, Text, x70 y85 r1 cBlue, %Model%
Gui, Add, Text, x17 y100 r1, LCD:
Gui, Add, Text, x70 y100 r1 cBlue, %LCD%
Gui, Add, Text, x17 y115 r1, CPU:
Gui, Add, Text, x70 y115 r1 cBlue, %Value1%
Gui, Add, Text, x17 y130 r1, OS:
Gui, Add, Text, x70 y130 r1 cBlue, %Value2%
Gui, Add, Text, x17 y145 r1, Warranty:
Gui, Add, Text, x70 y145 r1 cBlue, %Value3%
Gui, Add, Text, x17 y160 r1, Bay:
Gui, Add, Text, x70 y160 r1 cBlue, %Value4%
Gui, Add, Text, x17 y175 r1, Memory:
Gui, Add, Text, x70 y175 r1 cBlue
, % (Value5 + Value6) . " (" . Value5 . "+" . Value6 . ")"
Gui, Add, Text, x187 y85 r1, HDD:
Gui, Add, Text, x250 y85 r1 cBlue, %Value7%
Gui, Add, Text, x187 y100 r1, Com:
Gui, Add, Text, x250 y100 r1 cBlue, %Value8%
Gui, Add, Text, x187 y115 r1, Point Dev:
Gui, Add, Text, x250 y115 r1 cBlue, %Value9%
Gui, Add, Text, x187 y130 r1, Keyboard:
Gui, Add, Text, x250 y130 r1 cBlue, %Value10%
Gui, Add, Text, x187 y145 r1, FDD:
Gui, Add, Text, x250 y145 r1 cBlue, %Value11%
Gui, Add, Text, x187 y160 r1, Main Batt:
Gui, Add, Text, x250 y160 r1 cBlue, %Value12%
Gui, Add, Text, x187 y175 r1, 2nd Batt:
Gui, Add, Text, x250 y175 r1 cBlue, %Value13%
Return
; ##############################################################################
Field_OK(Config, S, I)
{
If (RegExMatch(Config, "`aim)^Field" . I . "=(.+)$", RX))
{
If S In %RX1%
{
Return True
} Else {
M := "Wrong Input at Position " . (I + 3)
M .= "`n`nValid Entries are : " . RX1
}
} Else {
M := "Field " . I . " is missing in Config File!"
}
MsgBox, %M%
Return False
} |
This is a sample config file ab.cfg for the model "AB" which is assumed to be in the script's folder:
| Code: | Model=AB
LCD=LCD 1
; CPU
Field1=1,2,3
Value1_1=CPU 1
Value1_2=CPU 2
Value1_3=CPU 3
; OS
Field2=1,2,3
Value2_1=OS 1
Value2_2=OS 2
Value2_3=OS 3
; Warranty
Field3=1,2,3
Value3_1=Warranty 1
Value2_2=Warranty 2
Value3_3=Warranty 3
; Bay
Field4=1,2,3
Value4_1=Bay 1
Value4_2=Bay 2
Value4_3=Bay 3
; Memory built-in
Field5=1,2,3
Value5_1=256
Value5_2=512
Value5_3=1024
; Memory extension
Field6=1,2,3
Value6_1=256
Value6_2=512
Value6_3=1024
; HDD
Field7=1,2,3
Value7_1=HDD 1
Value7_2=HDD 2
Value7_3=HDD 3
; COM
Field8=1,2,3
Value8_1=COM 1
Value8_2=COM 2
Value8_3=COM 3
; Point Dev
Field9=1,2,3
Value9_1=PDev 1
Value9_2=PDev 2
Value9_3=PDev 3
; Keyboard
Field10=1,2,3
Value10_1=Keyboard 1
Value10_2=Keyboard 2
Value10_3=Keyboard 3
; FDD
Field11=1,2,3
Value11_1=FDD 1
Value11_2=FDD 2
Value11_3=FDD 3
; Main Batt
Field12=1,2,3
Value12_1=MBatt 1
Value12_2=MBatt 2
Value12_3=MBatt 3
; 2nd Batt
Field13=1,2,3
Value13_1=2Batt 1
Value13_2=2Batt 2
Value13_3=2Batt 3
|
_________________ nick
denick @ http://de.autohotkey.com/forum/ |
|
| Back to top |
|
 |
madhatr
Joined: 10 Jan 2007 Posts: 33
|
Posted: Sun Jul 01, 2007 9:01 am Post subject: |
|
|
OK, I have been using your system and it is working wonderfully.
Due to the fact that many models have different layouts I was using a layout system like this: | Code: | If LAYOUT = 1
{
MODEL = %SERIES%
CPU = %Value#%
OS = %Value#%
WAR = %Value#%
BAY = %Value#%
MEM1 = %Value#%M
MEM2 = %Value#%M
HDD1 = %Value#%G
COM = %Value#%
POINT = %Value#%
KEYBOARD = %Value#%
FDD = %Value#%
BATT1 = %Value#%
BATT2 = %Value#%
LCD = %LCD%
SECHIP = %SECHIP%
HDD2 := "0"
SEC := "None"
ACC1 := "None"
ACC2 := "None"
ACC3 := "None"
EnvAdd, HDDADD, 2
HDDADD += 2
HDDTotal = %Value#%
HDDTotal += 0
HDDT = %HDDTOTAL%G
EnvAdd, Memadd, 2
Memadd += 2
MemTotal = %Value#%
MemTotal += %Value#%
MEMT = %MemTotal%M
Goto Output
Return
} |
Now there are so many layouts that I would like to move the layouts out to other files, this way new ones can be added without recompiling. I tried this: | Code: | FileRead, LAY, %CfgDir%LAYOUT%LAYOUT%.cfg
If (RegExMatch(LAY, "`aim)^CPU=(.+)$", RX)) {
CPU := RX1
}
If (RegExMatch(LAY, "`aim)^OS=(.+)$", RX)) {
OS := RX1
} |
Now of course OS does not equal the var of %Field#% but the word %Field#%. How would I go about making that the var instead of the literal string?
Thanks for all the help, and thanks in advance for anymore that can be given. |
|
| Back to top |
|
 |
nick
Joined: 24 Aug 2005 Posts: 345 Location: Berlin / Germany
|
Posted: Sun Jul 01, 2007 10:18 am Post subject: |
|
|
| Code: | #NoEnv
; Layout File
LAY =
(
MODEL=SERIES
CPU=Value1
OS=Value3
MEM1=Value9
)
MODEL := "Unknown"
CPU := "Unknown"
OS := "Unknown"
MEM1 := "Unknown"
SERIES := "ABC"
Value1 := "AMD Athlon 64"
Value3 := "Win XP"
Value9 := "1024"
Gosub, Get_Layout_Values
MsgBox, Model=%MODEL%`nCPU=%CPU%`nOS=%OS%`nMem1=%MEM1%
ExitApp
Get_Layout_Values:
If (RegExMatch(LAY, "`aim)^MODEL=(.+)$", RX)) {
MODEL := %RX1%
}
If (RegExMatch(LAY, "`aim)^CPU=(.+)$", RX)) {
CPU := %RX1%
}
If (RegExMatch(LAY, "`aim)^OS=(.+)$", RX)) {
OS := %RX1%
}
If (RegExMatch(LAY, "`aim)^MEM1=(.+)$", RX)) {
MEM1 := %RX1% . " M"
}
Return |
_________________ nick
denick @ http://de.autohotkey.com/forum/ |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|