0

我正在尝试将十六进制颜色值分配给数组。这是不可能的,因为当我分配值时,它会变成一个数字。这是执行此操作的代码:

settings := {myColor: "color"}

myColor := "color"

settingName := "myColor"
settingValue := "0x00FF00"


%settingName% := settingValue
settings[settingName] := settingValue

e := settings[settingName]
MsgBox %e% - %settingValue%
;Displays 65280 - 0x00FF00
4

1 回答 1

0

我认为您在第 5 行代码中出错了。您定义的变量没有 % 符号。

settings := {myColor: "color"}
myColor := "color"

settingName := "myColor"
settingValue := "0x00FF00"

settingName = %settingValue% ; Alternative 1
settingName := settingValue ; Alternative 2
settings[settingName] := settingValue
e := settings[settingName]
MsgBox % e " -  " settings[settingName] " - " settingValue
;Displays  0x00FF00 - 0x00FF00 - 0x00FF00
ExitApp

虽然我认为您想要:Settings[MyColor] = 0x00FF00,但您现在拥有 Settings[0x00FF00] = 0x00FF00。

settings := {myColor: "color"}
myColor := "color"

settingName := "myColor"
settingValue := "0x00FF00"
settings[settingName] := settingValue

MsgBox % settings[settingName] " - " settingValue
;Displays  0x00FF00 - 0x00FF00
ExitApp
于 2013-05-06T08:18:43.057 回答