求助 GUICtrlRead 读取循环判断选项是否正常(已解决)
本帖最后由 夜猫猫 于 2012-7-25 20:13 编辑反复测试还是不能正常工作,当勾择(备份到FTP服务器)时,FTP项目以后的全没反应.不能正常判断,不选时可以判断下面的.
选取时:
不选时:
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("数据库备份恢复-配置", 590, 471, 208, 114) ;,$WS_POPUP
$Group1 = GUICtrlCreateGroup("默认配置", 16, 16, 553, 157)
$Checkbox2 = GUICtrlCreateCheckbox("备份到FTP服务器", 112, 35, 130, 17)
$Checkbox3 = GUICtrlCreateCheckbox("备份到本地目录", 364, 35, 130, 17)
$Label1 = GUICtrlCreateLabel("服务器:", 34, 68, 52, 17)
GUICtrlSetTip (-1, "FTP地址,直接填IP","", 0, 1)
$Input1 = GUICtrlCreateInput("", 82, 64, 110, 21)
$Label2 = GUICtrlCreateLabel("用户名:", 218, 68, 52, 17)
GUICtrlSetTip (-1, "FTP用户名,需要FTP管理员权限","", 0, 1)
$Input2 = GUICtrlCreateInput("", 266, 64, 110, 21)
$Label3 = GUICtrlCreateLabel("密码:", 404, 68, 40, 17)
GUICtrlSetTip (-1, "FTP密码","", 0, 1)
$Input3 = GUICtrlCreateInput("", 440, 64, 110, 21)
$Label4 = GUICtrlCreateLabel("备份周期:", 34, 107, 64, 17)
GUICtrlSetTip (-1, "备份周期,每几小时备份一次","", 0, 1)
$Input4 = GUICtrlCreateInput("", 94, 104, 17, 17)
$Label5 = GUICtrlCreateLabel("/小时", 114, 107, 33, 17)
$Label6 = GUICtrlCreateLabel("保留备份次数:", 180, 107, 88, 17)
GUICtrlSetTip (-1, "需要保留备份次数","", 0, 1)
$Input5 = GUICtrlCreateInput("", 263, 104, 17, 17)
$Label7 = GUICtrlCreateLabel("/份", 283, 107, 21, 17)
$Checkbox1 = GUICtrlCreateCheckbox("压缩备份", 350, 105, 97, 17)
$Checkbox4 = GUICtrlCreateCheckbox("是否开机启动", 460, 105, 97, 17)
$Label8 = GUICtrlCreateLabel("远程路径:", 34, 144, 64, 17)
GUICtrlSetTip (-1, "远程路径,直接使用根目录)","", 0, 1)
$Input6 = GUICtrlCreateInput("PubwinDBBackup", 93, 140, 175, 21)
GUICtrlSetState($Input6, $GUI_DISABLE)
$Label9 = GUICtrlCreateLabel("本地路径:", 315, 144, 64, 17)
GUICtrlSetTip (-1, "本地路径,不用以”\“结束)","", 0, 1)
$Input7 = GUICtrlCreateInput("E:\PubwinBackup", 374, 140, 175, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup(" SQL数据库连接配置 ", 16, 188, 553, 213)
$Label10 = GUICtrlCreateLabel("服务器:", 55, 216, 52, 17)
GUICtrlSetTip (-1, "SQL服务器地址IP。本地为localhost或127.0.0.1","", 0, 1)
$Combo1 = GUICtrlCreateCombo("", 104, 212, 193, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "localhost|127.0.0.1", "")
$Label11 = GUICtrlCreateLabel("端口:", 321, 216, 40, 17)
GUICtrlSetTip (-1, "SQL服务器端口,默认为1433","", 0, 1)
$Combo2 = GUICtrlCreateCombo("", 359, 212, 169, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "1433", "")
$Group3 = GUICtrlCreateGroup(" SQL身份验证模式 ", 32, 244, 521, 141)
$Radio1 = GUICtrlCreateRadio("使用 Windows身份验证", 88, 266, 169, 17)
$Radio2 = GUICtrlCreateRadio("使用SQL Server身份验证", 88, 293, 169, 17)
GUICtrlSetState($radio1, $GUI_CHECKED)
$Label12 = GUICtrlCreateLabel("用户名:", 160, 323, 52, 17)
GUICtrlSetTip (-1, "连接SQL帐号,默认帐号为netcafe","", 0, 1)
$Input8 = GUICtrlCreateInput("", 208, 319, 233, 21)
$Label13 = GUICtrlCreateLabel("密码:", 171, 352, 40, 17)
GUICtrlSetTip (-1, '连接SQL密码,默认密码为"pubwin"',"", 0, 1)
$Input9 = GUICtrlCreateInput("", 208, 348, 233, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("SQL连接测试", 56, 410, 115, 25)
$Button2 = GUICtrlCreateButton("保存配置", 256, 410, 107, 25)
$Button3 = GUICtrlCreateButton("取消", 456, 410, 75, 25)
GUISetState(@SW_SHOW)
If GUICtrlRead($Radio1) = $GUI_CHECKED Then
GUICtrlSetState($Input8, $GUI_DISABLE)
GUICtrlSetState($Input9, $GUI_DISABLE)
EndIf
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
_Check()
Case $Radio1
GUICtrlSetState($Input8, $GUI_DISABLE)
GUICtrlSetState($Input9, $GUI_DISABLE)
Case $Radio2
GUICtrlSetState($Input8, $GUI_ENABLE)
GUICtrlSetState($Input9, $GUI_ENABLE)
Case $Checkbox2
If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
GUICtrlSetState($Input1, $GUI_ENABLE)
GUICtrlSetState($Input2, $GUI_ENABLE)
GUICtrlSetState($Input3, $GUI_ENABLE)
Else
GUICtrlSetState($Input1, $GUI_DISABLE)
GUICtrlSetState($Input2, $GUI_DISABLE)
GUICtrlSetState($Input3, $GUI_DISABLE)
EndIf
EndSwitch
WEnd
Func _Check()
If GUICtrlRead($Checkbox2) = $GUI_UNCHECKED And GUICtrlRead($Checkbox3) = $GUI_UNCHECKED Then
MsgBox(16,"错误!","请选择备份保存方式")
ElseIf GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
If GUICtrlRead($Input1)="" Then
MsgBox(16,"错误!","请输入FTP服务器地址")
ElseIf GUICtrlRead($Input2)="" Then
MsgBox(16,"错误!","请输入FTP登录帐号")
ElseIf GUICtrlRead($Input3)="" Then
MsgBox(16,"错误!","请输入FTP登录密码")
EndIf
ElseIf GUICtrlRead($Input4)="" Then
MsgBox(16,"错误!","请输入备份周期")
ElseIf GUICtrlRead($Input5)="" Then
MsgBox(16,"错误!","请输入保留备份次数")
;ElseIf GUICtrlRead($Input6)="" Then
; MsgBox(16,"错误!","请选择远程备份路径")
ElseIf GUICtrlRead($Input7)="" Then
MsgBox(16,"错误!","请选择本地备份路径")
ElseIf GUICtrlRead($Combo1)="" Then
MsgBox(16,"错误!","请输入SQL服务器地址")
ElseIf GUICtrlRead($Combo2) ="" Then
MsgBox(16,"错误!","请输入SQL服务器端口")
ElseIf GUICtrlRead($Radio2) = $GUI_CHECKED Then
IfGUICtrlRead($Input8) ="" Then
MsgBox(16,"错误!","请输入SQL登录帐号")
ElseIf GUICtrlRead($Input9)=""Then
MsgBox(16,"错误!","请输入SQL登录密码")
EndIf
EndIf
EndFunc
Func _Check()
If GUICtrlRead($Checkbox2) = $GUI_UNCHECKED And GUICtrlRead($Checkbox3) = $GUI_UNCHECKED Then Return MsgBox(16, "错误!", "请选择备份保存方式")
If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
If GUICtrlRead($Input1) = "" Then Return MsgBox(16, "错误!", "请输入FTP服务器地址")
If GUICtrlRead($Input2) = "" Then Return MsgBox(16, "错误!", "请输入FTP登录帐号")
If GUICtrlRead($Input3) = "" Then Return MsgBox(16, "错误!", "请输入FTP登录密码")
If GUICtrlRead($Input6) = "" Then Return MsgBox(16,"错误!","请选择远程备份路径")
Else
If GUICtrlRead($Input7) = "" Then Return MsgBox(16, "错误!", "请选择本地备份路径")
EndIf
If GUICtrlRead($Input4) = "" Then Return MsgBox(16, "错误!", "请输入备份周期")
If GUICtrlRead($Input5) = "" Then Return MsgBox(16, "错误!", "请输入保留备份次数")
If GUICtrlRead($Combo1) = "" Then Return MsgBox(16, "错误!", "请输入SQL服务器地址")
If GUICtrlRead($Combo2) = "" Then Return MsgBox(16, "错误!", "请输入SQL服务器端口")
If GUICtrlRead($Radio2) = $GUI_CHECKED Then
If GUICtrlRead($Input8) = "" Then Return MsgBox(16, "错误!", "请输入SQL登录帐号")
If GUICtrlRead($Input9) = "" Then Return MsgBox(16, "错误!", "请输入SQL登录密码")
EndIf
EndFunc ;==>_Check 谢谢斑竹! 基础不好就这样.....哎Return 谢谢斑竹! 基础不好就这样.....哎Return
夜猫猫 发表于 2012-7-25 20:13 http://www.autoitx.com/images/common/back.gif
能不能同样感叹一下呀! 本帖最后由 夜猫猫 于 2012-7-25 20:24 编辑
看了下UDF
Func...Return...EndFunc一头雾水, Return用来输出值..怎么判断?
特别是Func _() 括号里带参数的,不知道该如何解决....还是需要多研究这个了 看了下UDF
Func...Return...EndFunc一头雾水, Return用来输出值..怎么判断?
特别是Func _() 括号里带参 ...
夜猫猫 发表于 2012-7-25 20:21 http://www.autoitx.com/images/common/back.gif
你这主要问题出在使用了 ElseIf,属于判断条件的问题。加了 Return 只是代码比较精简而已,与你的错误没有直接联系。 飘过,前车之鉴 我也搞不清楚.我使用ElseIf那里出错了,但使用你的代码就能正常 都变成伸手党了...
页:
[1]