如果几个控件的动作一样,那么怎样写代码简洁?
如果几个控件的动作一样,那么怎样写代码简洁?本人菜鸟求助,如下例[*](action_tile"HR_H" (strcat "(setq $HRSType $key)" "(WriteREGvalue \"HRSECTION\" \"SelectedTYPE\" $key)" "(HRS_READ_DATA)" "(HRS_FILL_Size_LIST)" "(HRS_FILL_DES_LIST)"))
[*](action_tile"HR_I" (strcat "(setq $HRSType $key)" "(WriteREGvalue \"HRSECTION\" \"SelectedTYPE\" $key)" "(HRS_READ_DATA)" "(HRS_FILL_Size_LIST)" "(HRS_FILL_DES_LIST)"))
[*](action_tile"HR_QI" (strcat "(setq $HRSType $key)" "(WriteREGvalue \"HRSECTION\" \"SelectedTYPE\" $key)" "(HRS_READ_DATA)" "(HRS_FILL_Size_LIST)" "(HRS_FILL_DES_LIST)"))
[*](action_tile"HR_[" (strcat "(setq $HRSType $key)" "(WriteREGvalue \"HRSECTION\" \"SelectedTYPE\" $key)" "(HRS_READ_DATA)" "(HRS_FILL_Size_LIST)" "(HRS_FILL_DES_LIST)"))
[*](action_tile"HR_Q[" (strcat "(setq $HRSType $key)" "(WriteREGvalue \"HRSECTION\" \"SelectedTYPE\" $key)" "(HRS_READ_DATA)" "(HRS_FILL_Size_LIST)" "(HRS_FILL_DES_LIST)"))
[*](action_tile"HR_EQANG" (strcat "(setq $HRSType $key)" "(WriteREGvalue \"HRSECTION\" \"SelectedTYPE\" $key)" "(HRS_READ_DATA)" "(HRS_FILL_Size_LIST)" "(HRS_FILL_DES_LIST)"))
[*](action_tile"HR_UEQANG" (strcat "(setq $HRSType $key)" "(WriteREGvalue \"HRSECTION\" \"SelectedTYPE\" $key)" "(HRS_READ_DATA)" "(HRS_FILL_Size_LIST)" "(HRS_FILL_DES_LIST)"))
[*](action_tile"H" (strcat "(setq $HRSType $key)" "(WriteREGvalue \"HRSECTION\" \"SelectedTYPE\" $key)" "(HRS_READ_DATA)" "(HRS_FILL_Size_LIST)" "(HRS_FILL_DES_LIST)"))
[*](action_tile"HR_T" (strcat "(setq $HRSType $key)" "(WriteREGvalue \"HRSECTION\" \"SelectedTYPE\" $key)" "(HRS_READ_DATA)" "(HRS_FILL_Size_LIST)" "(HRS_FILL_DES_LIST)"))
[*](action_tile"HR_P" (strcat "(setq $HRSType $key)" "(WriteREGvalue \"HRSECTION\" \"SelectedTYPE\" $key)" "(HRS_READ_DATA)" "(HRS_FILL_Size_LIST)" "(HRS_FILL_DES_LIST)"))
[*](action_tile"HR_TUB" (strcat "(setq $HRSType $key)" "(WriteREGvalue \"HRSECTION\" \"SelectedTYPE\" $key)" "(HRS_READ_DATA)" "(HRS_FILL_Size_LIST)" "(HRS_FILL_DES_LIST)"))
这11个按钮的动作一样.谢谢
(foreach Key '("HR_H" "HR_I" "HR_[" "HR_Q[" "HR_EQANG" "HR_UEQANG" "HR_T" "HR_P" "HR_TUB")
(action_tile Key "(setq $HRSType $key)
(WriteREGvalue \"HRSECTION\" \"SelectedTYPE\" $key)
(HRS_READ_DATA)" "(HRS_FILL_Size_LIST)
(HRS_FILL_DES_LIST)
"
)
)
(defun abc ()
(setq $HRSType $key)
(WriteREGvalue "HRSECTION" "SelectedTYPE" $key)
(HRS_READ_DATA)
(HRS_FILL_Size_LIST)
(HRS_FILL_DES_LIST)
)
(foreach a '("HR_H" "HR_I" "HR_QI" "HR_[" "HR_Q[" "HR_EQANG" "HR_UEQANG" "H" "HR_T" "HR_P" "HR_TUB")
(action_tile a (abc))
)
多谢两位,学习了。回头看看我写的那个,惨不忍睹!啊
页:
[1]