Please check this code for any further optimization
Posted: 18 Mar 2011 06:01
Hi Guys,
I am developing a code where function "done_send_to_engine" will take either single or double inputs
so before sending to this function I'll check whether they are null or not using below script snippet
Input Menu
Enter IP's
Start :
End :
so after taking the IP's from the above menu I'll check whether there are 2 IP's or only single IP
single IP can be entered either on Start or End so my code checks and pass it to my processing engine function "done_send_to_engine". If both are filled Start and End then my engine function will pin sweep all those IP's
if either Start or End are entered then my engine will ping only that machine. please review my below code and
check whether any further optimizations can be done.
:validate_inputs
SETLOCAL
set val_1=%1
set val_2=%2
if "%val_1%" EQU "" (set val1=0&&call:check_val_2) else (set val1=1&&call:check_val_2)
:check_val_2
if "%val1%" EQU 0 (call:check_val_2_for_0)
if "%val1%" EQU 1 (call:check_val_2_for_1)
:check_val_2_for_0
if "%val_2%" EQU "" (call:null_input) else (call:done_send_to_engine %val_2%)
:check_val_2_for_1
if "%val_2%" EQU "" (call:done_send_to_engine %val_1%) else (call:done_send_to_engine %val_1% %val_2%)
ENDLOCAL
Thanks
I am developing a code where function "done_send_to_engine" will take either single or double inputs
so before sending to this function I'll check whether they are null or not using below script snippet
Input Menu
Enter IP's
Start :
End :
so after taking the IP's from the above menu I'll check whether there are 2 IP's or only single IP
single IP can be entered either on Start or End so my code checks and pass it to my processing engine function "done_send_to_engine". If both are filled Start and End then my engine function will pin sweep all those IP's
if either Start or End are entered then my engine will ping only that machine. please review my below code and
check whether any further optimizations can be done.
:validate_inputs
SETLOCAL
set val_1=%1
set val_2=%2
if "%val_1%" EQU "" (set val1=0&&call:check_val_2) else (set val1=1&&call:check_val_2)
:check_val_2
if "%val1%" EQU 0 (call:check_val_2_for_0)
if "%val1%" EQU 1 (call:check_val_2_for_1)
:check_val_2_for_0
if "%val_2%" EQU "" (call:null_input) else (call:done_send_to_engine %val_2%)
:check_val_2_for_1
if "%val_2%" EQU "" (call:done_send_to_engine %val_1%) else (call:done_send_to_engine %val_1% %val_2%)
ENDLOCAL
Thanks