Page 1 of 1

Is there a better way to do this

PostPosted: Fri Oct 10, 2014 5:54 am
by stevec
I have an application that checks to see if a check box is checked, if it is it runs a routine (an app install) and then goes on to the next checkbox.

Here is a section of code


If "[CheckBox3]" "<>" "checked"
GotoLine "54"
Else
If "[CheckBox3]" "=" "checked"
Run "G:\Citywide\XXX\XXX\XXXXs\XXXXX\XXXXX\Setup.exe" "-qb G:\Citywide\XXXX\XXXXX\XXXX\XXXX\XXXXX\XXXXSetup_MST" "RunOnce+Wait" "" ""
Delay "200"
GotoLine "54"
If "[CheckBox4]" "<>" "checked"
GotoLine "59"
Else
If "[CheckBox4]" "=" "checked"
Run "C:\Program Files\Internet Explorer\iexplore.exe" "http://XXXXXX/Inspections/publish.htm" "Wait+LoadComplete" "" ""
GotoLine "60"
If "[CheckBox5]" "<>" "checked"
GotoLine "66"
Else
If "[CheckBox5]" "=" "checked"
DOSCommand "msiexec" " /i G:\Department\XXX\XXXX\XXXXX\XXXXXs.msi" "RunOnce+Wait"
GotoLine "66"

currently the only way I have managed to get this to work is to have it check to see if the specified checkbox is checked, if not than go to a specific line, (check the next checkbox)
and so on, with an "else" command, if it is checked.

is there a better way to do this?

Re: Is there a better way to do this

PostPosted: Fri Oct 10, 2014 8:11 am
by Wrangler
seems you're missing a bunch of ENDIF's and you don't need the extra 'if' in each:

If "[CheckBox3]" "<>" "checked"
GotoLine "54"
Else
Run "G:\Citywide\XXX\XXX\XXXXs\XXXXX\XXXXX\Setup.exe" "-qb G:\Citywide\XXXX\XXXXX\XXXX\XXXX\XXXXX\XXXXSetup_MST" "RunOnce+Wait" "" ""
Delay "200"
GotoLine "54"
ENDIF

Then do this for each checkbox.

Re: Is there a better way to do this

PostPosted: Fri Oct 10, 2014 8:31 am
by stevec
Wrangler

Thanks for the reply.

The section that I posted was just a small section. The code is about 115 lines.
It's an install process that installs app's on a newly imaged PC, hence it doesn't (endif) till it finishes going through the installs that are requested.

I was hoping to figure out a way to have go to the next [checkbox] in the process with maybe a subroutine, as I might add another install and going
back to edit the [GoToLine] has been a chore.


Here is what

If "[CheckBoxX]" "<>" "checked"
GotoLine "{NEXT CHECKBOX-X}"
Else
Run "Install app" "RunOnce+Wait" "" ""
Delay "200"
GotoLine "{NEXT CHECKBOX-X}"
Delay
If "[CheckBoxX]" "<>" "checked"
GotoLine "{NEXT CHECKBOX-X}"
Else
Run "Install app" "RunOnce+Wait" "" ""
Delay "200"
GotoLine "{NEXT CHECKBOX-X}"
Delay
If "[CheckBoxX]" "<>" "checked"
GotoLine "{NEXT CHECKBOX-X}"
Else
Run "Install app" "RunOnce+Wait" "" ""
Delay "200"
GotoLine "{NEXT CHECKBOX-X}"
EndIf

Re: Is there a better way to do this

PostPosted: Fri Oct 10, 2014 9:34 am
by Gaev
Steve:

back to edit the [GoToLine] has been a chore.

While use of the GoToLine command has been frowned/discouraged (in all computer languages) for a very long time ... and you can build your Application/Logic without them ... note that NeoBook's command will also accept a Label instead of a LineNumber e.g.

GoTo "Check2"

... where Check2 is defined like so ...

:Check2

... similar to start of SubRoutines

This type of code should do what you want ...
Code: Select all
If "[CheckBoxA]" "=" "checked"
   Run "Install app" "RunOnce+Wait" "" ""
   Delay "200"
EndIf
If "[CheckBoxB]" "=" "checked"
   Run "Install app" "RunOnce+Wait" "" ""
   Delay "200"
EndIf
If "[CheckBoxC]" "=" "checked"
   Run "Install app" "RunOnce+Wait" "" ""
   Delay "200"
EndIf
etc. etc.


So, if [CheckBoxA] is NOT checked, NeoBook will continue the script at the command AFTER the first EndIf command ... and if [CheckBoxB] is NOT checked, NeoBook will continue the script at the command AFTER the second EndIf command.

Re: Is there a better way to do this

PostPosted: Fri Oct 10, 2014 10:11 am
by stevec
Thanks;
I think that this is a much better (cleaner) way and the I don't have to worry about the #line code and I can add to it.

Thnaks;

Re: Is there a better way to do this

PostPosted: Fri Oct 10, 2014 6:04 pm
by mishem
Code: Select all
StrParse "CheckBoxA,CheckBoxB,CheckBoxC" "," "[CheckBox]" "[num]"
StrParse "Install app A,Install app B,Install app C" "," "[Install_app]" ""

Loop "1" "[num]" "[i]"
    If "[[CheckBox[i]]]" "=" "checked"
        Run "[Install_app[i]]" "RunOnce+Wait" "" ""
        ExitLoop
    EndIf
EndLoop

Re: Is there a better way to do this

PostPosted: Tue Oct 14, 2014 2:48 pm
by stevec
Thanks;
I'll give give this a try and keep it in my file.
Thanks!

Re: Is there a better way to do this

PostPosted: Wed Oct 15, 2014 8:50 am
by stevec
I am slightly confused when I tried to use the code.

StrParse "CheckBoxA,CheckBoxB,CheckBoxC" "," "[CheckBox]" "[num]"
StrParse "Install app A,Install app B,Install app C" "," "[Install_app]" ""

Loop "1" "[num]" "[i]"
If "[[CheckBox[i]]]" "=" "checked"
Run "[Install_app[i]]" "RunOnce+Wait" "" ""
ExitLoop
EndIf
EndLoop

1. Where do I add the instructions for the app installs, such as C:\temp\setup.exe?

2. If I add another checkbox do I have to add 'CheckboxD' to the StrParse line.

Thanks;

Re: Is there a better way to do this

PostPosted: Wed Oct 15, 2014 11:20 am
by mishem
StrParse "CheckBoxA,CheckBoxB,CheckBoxC,CheckboxD" "," "[CheckBox]" "[num]"
StrParse "Install app A,Install app B,Install app C,C:\temp\setup.exe" "," "[Install_app]" ""