Показать полную графическую версию : [решено] Разбить данные одной строки по полям формы
support23
18-09-2012, 13:41
Доброго дня,
есть форма с полями:
$pochta = GUICtrlCreateInput('', 15, 10, 185, 21)
GUICtrlCreateLabel (" - Адрес почты", 210, 13)
$login = GUICtrlCreateInput('', 15, 40, 185, 21)
GUICtrlCreateLabel (" - Логин", 210, 43)
$surname = GUICtrlCreateInput('', 15, 70, 185, 21)
GUICtrlCreateLabel (" - Фамилия", 210, 70)
$name = GUICtrlCreateInput('', 15, 100, 185, 21)
GUICtrlCreateLabel (" - Имя", 210, 100)
$first = GUICtrlCreateInput('', 15, 135, 185, 21)
GUICtrlCreateLabel (" - Отчество", 210, 135)
есть строка: Фамилия Имя Отчество <login@server.ru>
как данные из строки разбить по соответствующим полям, фамилия отдельно, имя отдельно, и т.д. ?
например ввел строку - Фамилия Имя Отчество <login@server.ru> нажал кнопку, и заполнились поля формы.
как данные из строки разбить по соответствующим полям, фамилия отдельно, имя отдельно, и т.д. ? »
#include (http://autoit-script.ru/autoit3_docs/keywords.htm##include) <GUIConstantsEx.au3>
$hGUI = GUICreate (http://autoit-script.ru/autoit3_docs/functions/GUICreate.htm)('Test Script', 300, 300)
$pochta = GUICtrlCreateInput (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateInput.htm)('', 15, 10, 185, 21)
GUICtrlCreateLabel (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateLabel.htm)(" - Адрес почты", 210, 13)
$login = GUICtrlCreateInput (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateInput.htm)('', 15, 40, 185, 21)
GUICtrlCreateLabel (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateLabel.htm)(" - Логин", 210, 43)
$surname = GUICtrlCreateInput (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateInput.htm)('', 15, 70, 185, 21)
GUICtrlCreateLabel (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateLabel.htm)(" - Фамилия", 210, 70)
$name = GUICtrlCreateInput (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateInput.htm)('', 15, 100, 185, 21)
GUICtrlCreateLabel (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateLabel.htm)(" - Имя", 210, 100)
$first = GUICtrlCreateInput (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateInput.htm)('', 15, 135, 185, 21)
GUICtrlCreateLabel (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateLabel.htm)(" - Отчество", 210, 135)
$iFill_Bttn = GUICtrlCreateButton (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateButton.htm)('Заполнить', 15, 270, 70, 20)
GUISetState (http://autoit-script.ru/autoit3_docs/functions/GUISetState.htm)(@SW_SHOW (http://autoit-script.ru/autoit3_docs/macros.htm#@sw_show), $hGUI)
While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
$nMsg = GUIGetMsg (http://autoit-script.ru/autoit3_docs/functions/GUIGetMsg.htm)()
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $nMsg
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $iFill_Bttn
$sLine = 'Фамилия Имя Отчество <login@server.ru>'
$aInputs = StringSplit (http://autoit-script.ru/autoit3_docs/functions/StringSplit.htm)($sLine, ' ')
$sLogin = StringRegExpReplace (http://autoit-script.ru/autoit3_docs/functions/StringRegExpReplace.htm)($sLine, '.*?<(.*?)@.*', '\1')
GUICtrlSetData (http://autoit-script.ru/autoit3_docs/functions/GUICtrlSetData.htm)($pochta, $aInputs[4])
GUICtrlSetData (http://autoit-script.ru/autoit3_docs/functions/GUICtrlSetData.htm)($login, $sLogin)
GUICtrlSetData (http://autoit-script.ru/autoit3_docs/functions/GUICtrlSetData.htm)($surname, $aInputs[1])
GUICtrlSetData (http://autoit-script.ru/autoit3_docs/functions/GUICtrlSetData.htm)($name, $aInputs[2])
GUICtrlSetData (http://autoit-script.ru/autoit3_docs/functions/GUICtrlSetData.htm)($first, $aInputs[3])
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)
support23
19-09-2012, 09:23
Спасибо!
А можно его немного исправить, чтобы адрес почты оставался без < > , и Фамилия Имя Отчество <login@server.ru> я мог вводит не в теле скрипта, а через GUICtrlCreateInput ?
можно его немного исправить, чтобы адрес почты оставался без < > , и Фамилия Имя Отчество <login@server.ru> я мог вводит не в теле скрипта, а через GUICtrlCreateInput ? »
#include (http://autoit-script.ru/autoit3_docs/keywords.htm##include) <GUIConstantsEx.au3>
$hGUI = GUICreate (http://autoit-script.ru/autoit3_docs/functions/GUICreate.htm)('Test Script', 300, 300)
$iPochta_Input = GUICtrlCreateInput (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateInput.htm)('', 15, 10, 185, 21)
GUICtrlCreateLabel (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateLabel.htm)(" - Адрес почты", 210, 13)
$iLogin_Input = GUICtrlCreateInput (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateInput.htm)('', 15, 40, 185, 21)
GUICtrlCreateLabel (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateLabel.htm)(" - Логин", 210, 43)
$iSurName_Input = GUICtrlCreateInput (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateInput.htm)('', 15, 70, 185, 21)
GUICtrlCreateLabel (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateLabel.htm)(" - Фамилия", 210, 70)
$iName_Input = GUICtrlCreateInput (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateInput.htm)('', 15, 100, 185, 21)
GUICtrlCreateLabel (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateLabel.htm)(" - Имя", 210, 100)
$iFirst_Input = GUICtrlCreateInput (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateInput.htm)('', 15, 135, 185, 21)
GUICtrlCreateLabel (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateLabel.htm)(" - Отчество", 210, 135)
$iData_Input = GUICtrlCreateInput (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateInput.htm)('Фамилия Имя Отчество <login@server.ru>', 15, 220, 185, 21)
GUICtrlCreateLabel (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateLabel.htm)(" - Данные", 210, 220)
$iFill_Bttn = GUICtrlCreateButton (http://autoit-script.ru/autoit3_docs/functions/GUICtrlCreateButton.htm)('Заполнить', 15, 270, 70, 20)
GUISetState (http://autoit-script.ru/autoit3_docs/functions/GUISetState.htm)(@SW_SHOW (http://autoit-script.ru/autoit3_docs/macros.htm#@sw_show), $hGUI)
While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
$nMsg = GUIGetMsg (http://autoit-script.ru/autoit3_docs/functions/GUIGetMsg.htm)()
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $nMsg
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $iFill_Bttn
$sLine = GUICtrlRead (http://autoit-script.ru/autoit3_docs/functions/GUICtrlRead.htm)($iData_Input)
$aInputs = StringSplit (http://autoit-script.ru/autoit3_docs/functions/StringSplit.htm)($sLine, ' ')
$sLogin = StringRegExpReplace (http://autoit-script.ru/autoit3_docs/functions/StringRegExpReplace.htm)($sLine, '.*?<(.*?)@.*', '\1')
GUICtrlSetData (http://autoit-script.ru/autoit3_docs/functions/GUICtrlSetData.htm)($iPochta_Input, StringRegExpReplace (http://autoit-script.ru/autoit3_docs/functions/StringRegExpReplace.htm)($aInputs[4], '^<|>$', ''))
GUICtrlSetData (http://autoit-script.ru/autoit3_docs/functions/GUICtrlSetData.htm)($iLogin_Input, $sLogin)
GUICtrlSetData (http://autoit-script.ru/autoit3_docs/functions/GUICtrlSetData.htm)($iSurName_Input, $aInputs[1])
GUICtrlSetData (http://autoit-script.ru/autoit3_docs/functions/GUICtrlSetData.htm)($iName_Input, $aInputs[2])
GUICtrlSetData (http://autoit-script.ru/autoit3_docs/functions/GUICtrlSetData.htm)($iFirst_Input, $aInputs[3])
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)
support23
19-09-2012, 14:01
Большое спасибо! То что нужно!
То что нужно! »
По решению проблемы тему принято отмечать решённой (вверху темы).
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.