Source language: Translate to:

Is there a better way to do this

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Is there a better way to do this

Postby stevec » Fri Oct 10, 2014 5:54 am

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?
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Re: Is there a better way to do this

Postby Wrangler » Fri Oct 10, 2014 8:11 am

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.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Re: Is there a better way to do this

Postby stevec » Fri Oct 10, 2014 8:31 am

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
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Re: Is there a better way to do this

Postby Gaev » Fri Oct 10, 2014 9:34 am

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.
User avatar
Gaev
 
Posts: 3736
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Is there a better way to do this

Postby stevec » Fri Oct 10, 2014 10:11 am

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;
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Re: Is there a better way to do this

Postby mishem » Fri Oct 10, 2014 6:04 pm

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
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Is there a better way to do this

Postby stevec » Tue Oct 14, 2014 2:48 pm

Thanks;
I'll give give this a try and keep it in my file.
Thanks!
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Re: Is there a better way to do this

Postby stevec » Wed Oct 15, 2014 8:50 am

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;
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Re: Is there a better way to do this

Postby mishem » Wed Oct 15, 2014 11:20 am

StrParse "CheckBoxA,CheckBoxB,CheckBoxC,CheckboxD" "," "[CheckBox]" "[num]"
StrParse "Install app A,Install app B,Install app C,C:\temp\setup.exe" "," "[Install_app]" ""
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 3 guests