Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::: Disable Command line commands from diplaying
- @ECHO OFF
- ::: Define Size of the Console Window
- Mode Con: cols=125 lines=25
- ::: Select Name of the Command Window
- TITLE Introduction to Batch User Interfaces.
- :intro
- ::: Define Variable Names For Page text
- Call :nullsentences
- ::: Establishes handling of page selection
- Set returnpage=intro
- Set targetpage=setup
- ::: Assigns text to the User Interface Screen Header.
- Set headertext=[31mIntroduction to Batch User Interface and Choice Command[32m
- ::: Assigns text to the screens textfield
- Set Sentence1=[37mWelcome to my Advanced batch Interface Tutorial.[32m
- Set Sentence2=[36mWe'll be covering everything needed to be able to reproduce[32m
- Set Sentence3=[36mthe format of this batch file.[32m
- Set Sentence4=[36mAll the [33mcommands[36m used to achieve this style of user interface[32m
- Set Sentence5=[36mare [35msimple[36m to master, however provide a much better user[32m
- Set Sentence6=[36mexperience than typical batch inteface menus.[32m
- Set sentence7=[36mAll commands will appear in [33mYellow[32m
- Set sentence8= [34mLet's take a look...[32m
- GOTO pagenext
- :setup
- Set returnpage=intro
- Set targetpage=bldscr1
- Call :nullsentences
- Set headertext=[31mSetting up your Script.[32m
- Set Sentence1=[37mThe First line of your script will be:[32m
- Set Sentence2=[33m^@ECHO OFF[32m
- Set Sentence3=[36mThe next command you have a bit of freedom with, as it depends on what size you[32m
- Set Sentence4=[36mwant your console to display at. [1m[33m"cols"[0m [36mdefines how wide,[1m[33m "lines"[0m[36m defines how high.[32m
- Set Sentence5=[33mMode con: cols=125 lines=25[32m
- Set Sentence6=[36mNext up, it's time to choose a [1m[33mtitle[0m[36m for your program.[32m
- Set Sentence7=[33mTITLE Introduction to Batch User Interfaces.[32m
- Set Sentence8=[34mNow that we've set up the basic properties of our console, [34mLet's build our display...[32m
- GOTO pageboth
- :bldscr1
- Set returnpage=setup
- Set targetpage=bldscr2
- Call :nullsentences
- Set headertext=[31mCreating your Screen Template[32m
- Set sentence1=[36mTo save alot of time and effort, Create a [34mtemplate[36m for the screens display that allows you to[32m
- Set sentence2=[36measily change the information presented to the user by changing a few variables then calling the screen.[32m
- Set sentence3=[36mIt's up to you to choose what sort of border you wish to place around your text field and what variable names you[32m
- Set sentence4=[36mwish to use to diplay the text. To make life easier, Variables with descriptive names are best.[32m
- Set sentence5=[36mYour [34mscreen[36m should be called from each page that wishes to use it. To call a label, use the following[32m
- Set sentence6=[33mCALL :screen[32m
- Set sentence7=[36mSubstitute [1m[33mscreen[0m[36m for the label name you wish to use / call.[32m
- Set sentence8=[34mNext up, we'll look at the screen template for this program.[32m
- GOTO pageboth
- :::
- :bldscr2
- Set returnpage=bldscr1
- Set targetpage=bldscr3
- Call :nullsentences
- Set sentence1=[33m:screen[32m [36mThe label name for this programs [34mScreen[36m template[32m
- Set sentence2=[33mcls [36mClears the [1m[33mConsole screen[0m[32m
- Set sentence3=[33mcolor 02 [36mSets the default [1m[33mColor[0m [36mof the background and text[32m
- Set sentence4=[33mIF ^%%avprev^%%==0 Set prev=*ESC[90m(P)revious*ESC[32m [36mThe variables [37m^%%avprev^%%/^%%avnext^%%[36m Display current navigation options.[32m
- Set sentence5=[33mIF ^%%avprev^%%==1 Set prev=*ESC[35m(P)revious*ESC[32m[32m
- Set sentence6=[33mIF ^%%avnext^%%==0 Set next=*ESC[90m(N)ext*ESC[32m[32m
- Set sentence7=[33mIF ^%%avnext^%%==1 Set next=*ESC[35m(N)ext*ESC[32m[32m
- Set sentence8=[37m*ESC is to be substituted for the ANSI escape symbol. [34mContinued...[32m
- GOTO pageboth
- :bldscr3
- Set returnpage=bldscr2
- Set targetpage=bldscr4
- Call :nullsentences
- Set headertext=[31mCreating your Screen Template[32m
- Set sentence1=[36mAdjust the border for your header to the style you desire.[32m
- Set sentence2=[33m^ECHO ====================================================================================================================[32m
- Set sentence3=[33m^ECHO ^%%header^%%*ESC[32m [36mDisplays the text stored to the [1m[33mVariable[0m [37mheader[32m
- Set sentence4=[33m^ECHO ====================================================================================================================[32m
- Set sentence5=
- Set sentence6=
- Set sentence7=
- Set sentence8=[34mContinued...[32m
- GOTO pageboth
- :bldscr4
- Set returnpage=bldscr3
- Set targetpage=bldscr5
- Call :nullsentences
- Set sentence1=[36mSpace out (our group) your sentences as you wish.[32m
- Set sentence2=[33m^ECHO = ^%%sentence1^%% [36mDisplays the text stored to the [1m[33mVariable[0m [34mSentence1[32m
- Set sentence3=[33m^ECHO =[32m
- Set sentence4=[33m^ECHO = ^%%sentence2^%%[32m
- Set sentence5=[33m^ECHO =[32m
- Set sentence6=[33m^ECHO = ^%%sentence3^%%[32m
- Set sentence7=[37mThis Tutorial uses 8 sentences with spaces to keep information clearly divided.[32m
- Set sentence8=
- GOTO pageboth
- :bldscr5
- Set returnpage=bldscr4
- Set targetpage=prptmp1
- Call :nullsentences
- Set sentence1=[36mDisplay the navigation options Available to the user, and return to the place in the program[32m
- Set sentence2=[36mfrom which you called your screen.[32m
- Set sentence3=[33m^ECHO ====================================================================================================================[32m
- Set sentence4=[33m^ECHO [33m^%%prev^%% ^%%next^%%[32m
- Set sentence5=[33m^ECHO ====================================================================================================================[32m
- Set sentence6=[33m^GOTO :EOF[32m
- Set sentence7=[36mIf you have other options for the user to take, You can easily Incorperate them into your [34mHeader[36m Variable.[32m
- Set sentence8=[36mIn labels that offer additional options, use: [33mSet header=Option (1) Option (2) Option (3) [36m etc...[32m
- GOTO pageboth
- :prptmp1
- Set returnpage=bldscr5
- Set targetpage=prptmp2
- Set headertext=[31mPreparing to use your template.[32m
- Call :nullsentences
- Set sentence1=[36mChances are, your not going to fill every sentence on every screen your program uses.[32m
- Set sentence2=[36mBecause of this, you need to clear the variables before getting ready to call your screen.[32m
- Set sentence3=[36mTo do this. create another function to call from pages that call your screen.[32m
- Set sentence4=[33m :nullsentences[32m
- Set sentence5=[33m Set Sentence1=[32m
- Set sentence6=[33m Set Sentence2=[36m Repeat this for the number of sentences your screen uses.[32m
- Set sentence7=[33m Set Sentence8=[36m You can also copy the Setting component of this function when you're preparing sentences.[32m
- Set sentence8=[33m GOTO :EOF[32m
- GOTO pageboth
- :prptmp2
- Set returnpage=prptmp1
- Set targetpage=explainchoice
- Set headertext=[31mPutting the template to use.[32m
- Call :nullsentences
- Set sentence1=[36mPrior to Setting your [37mSentence[36m Variables, you want to refresh them.[32m
- Set sentence2=[33mCall :nullsentences[32m
- Set sentence3=[36mNow Set your Sentences.[32m
- Set sentence4=[33mSet sentence1=*ESC[36mPrior to Setting your *ESC[37mSentence*ESC[36m Variables, you want to refresh them.*ESC[32m[32m
- Set sentence5=[33mSet sentence2=*ESC[33mCall :nullsentences*ESC[32m[32m
- Set sentence6=[33mSet sentence3=*ESC[36mNow Set your Sentences.*ESC[32m[32m
- Set sentence7=[36mNext up, I'll be explaining [1m[33mCHOICE[0m [36mSelection and Basic Navigation for your [34mInterface[32m
- Set sentence8=
- GOTO pageboth
- :explainchoice
- Set returnpage=prptmp2
- Set targetpage=optionselect
- Set headertext=[31mCHOICE and Navigation[32m
- Call :nullsentences
- Set sentence1=[36mThe [1m[33mCHOICE[0m[36m command is what allows your user to interact with the user Interface.[32m
- Set sentence2=[36mFor paging through labels, as this program has so far, assigning label names to variables[32m
- Set sentence3=[36mis the way to go. In each 'page', prior to the choice command:[32m
- Set sentence4=[33m^Set targetpage=nextpagelabelname[32m
- Set sentence5=[33m^Set returnpage=lastpagelabelname[32m
- Set sentence6=[33m^CHOICE /N /C:pn /M ""^%%1[32m
- Set sentence7=[33mIF ERRORLEVEL ==2 GOTO ^%%targetpage^%%[32m
- Set sentence8=[33mIF ERRORLEVEL ==1 GOTO ^%%returnpage^%%[32m
- GOTO pageboth
- :optionselect
- Set returnpage=explainchoice
- Set targetpage=usetmplte
- Set headertext=[31m^CHOICE and Navigation[32m
- Call :nullsentences
- Set sentence1=[36mFor multi Directional paging, this program uses the following function[32m
- Set sentence2=[33m^:pageboth[32m
- Set sentence3=[33m^Set avnext=1[32m
- Set sentence4=[33m^set avprev=1[32m
- Set sentence5=[33m^Call :screen[32m
- Set sentence6=[33m^CHOICE /N /C:pn /M ""^%%1[32m
- Set sentence7=[33m^IF ERRORLEVEL ==2 GOTO ^%%targetpage^%%[32m
- Set sentence8=[33m^IF ERRORLEVEL ==1 GOTO ^%%returnpage^%%[32m
- GOTO pageboth
- :usetmplte
- Set returnpage=optionselect
- Set targetpage=wrapup
- Set headertext=[31mPutting it all together.[32m
- Set avnext=1
- set avprev=1
- cls
- IF %avprev%==0 Set prev=[90m(P)revious[32m
- IF %avprev%==1 Set prev=[35m(P)revious[32m
- IF %avnext%==0 Set next=[90m(N)ext[32m
- IF %avnext%==1 Set next=[35m(N)ext[32m
- ECHO ============================================================================================================================
- ECHO = %headertext%
- ECHO ============================================================================================================================
- ECHO =
- ECHO = [36mUsing the screen template becomes as simple as Copying code and changing the value of the variables and label names:[32m
- ECHO =
- ECHO = [33m:nameofcurrentlabel[32m
- ECHO = [33mCall :nullsentences[32m
- ECHO = [33mSet Sentence1= blah blah[32m
- ECHO = [33mSet Sentence2= blah blah[32m
- ECHO = [33mSet Sentence3= blah blah[32m
- ECHO = [33mSet Sentence4= blah blah[32m
- ECHO = [33mSet Sentence5= blah blah[32m
- ECHO = [33mSet Sentence6= blah blah[32m
- ECHO = [33mSet Sentence7= blah blah[32m
- ECHO = [33mSet Sentence8= blah blah[32m
- ECHO = [33mSet returnpage=nameofpreviouslabel[32m
- ECHO = [33mSet targetpage=nameofnextlabel[32m
- ECHO = [33mSet headertext=Desired Header Text[32m
- ECHO = [33mGOTO pageboth[36m Or [33mCall :screen [36mfollowed by other [1m[33mchoices[0m[36m as required.[32m
- ECHO ============================================================================================================================
- ECHO = %prev% %next%
- ECHO ============================================================================================================================
- CHOICE /T 5 /C pn /N /D n >nul
- IF ERRORLEVEL ==2 GOTO %targetpage%
- IF ERRORLEVEL ==1 GOTO %returnpage%
- :wrapup
- Set returnpage=usetmplte
- Set targetpage=wrapup
- Set headertext=[31mThe TakeAway.[32m
- Call :nullsentences
- Set sentence1=[36mAs you will have learned by now, with just a few [33mcommands[36m, a very simple yet informative [34mUser Interface[32m
- Set sentence2=[36mcan be made for batch files.[32m
- Set sentence3=[36mA little bit of [34mformatting[36m to display information clearly[32m
- Set sentence4=[36mA touch of [1m[31mColor[0m[36m to [37mhighlight[36m important [34minformation[36m or show [90mavail[35mble[36m options[32m
- Set sentence5=[4m[36mIs all it takes to make batch programs a more enjoyable experience.[0m[32m
- Set sentence6=
- Set sentence7=[36mFor a copy of this program, Visit: [37mhttps://pastebin.com/jbXyaPwN[32m
- Set sentence8=
- GOTO prevpage
- :::
- :nullsentences
- Set sentence1=
- Set sentence2=
- Set sentence3=
- Set sentence4=
- Set sentence5=
- Set sentence6=
- Set sentence7=
- Set sentence8=
- GOTO :EOF
- :pagenext
- Set avnext=1
- set avprev=0
- Call :screen
- CHOICE /T 5 /C pn /N /D n >nul
- IF ERRORLEVEL ==2 GOTO %targetpage%
- IF ERRORLEVEL ==1 GOTO %returnpage%
- :pageboth
- Set avnext=1
- set avprev=1
- Call :screen
- CHOICE /T 5 /C pn /N /D n >nul
- IF ERRORLEVEL ==2 GOTO %targetpage%
- IF ERRORLEVEL ==1 GOTO %returnpage%
- :prevpage
- Set avnext=0
- set avprev=1
- Call :screen
- CHOICE /T 5 /C pn /N /D n >nul
- IF ERRORLEVEL ==2 GOTO %targetpage%
- IF ERRORLEVEL ==1 GOTO %returnpage%
- :screen
- cls
- color 02
- IF %avprev%==0 Set prev=[90m(P)revious[32m
- IF %avprev%==1 Set prev=[35m(P)revious[32m
- IF %avnext%==0 Set next=[90m(N)ext[32m
- IF %avnext%==1 Set next=[35m(N)ext[32m
- ECHO ============================================================================================================================
- ECHO = %headertext%
- ECHO ============================================================================================================================
- ECHO =
- ECHO = %sentence1%
- ECHO =
- ECHO = %sentence2%
- ECHO =
- ECHO = %sentence3%
- ECHO =
- ECHO = %sentence4%
- ECHO =
- ECHO = %sentence5%
- ECHO =
- ECHO = %sentence6%
- ECHO =
- ECHO = %sentence7%
- ECHO =
- ECHO = %sentence8%
- ECHO =
- ECHO ============================================================================================================================
- ECHO = %prev% %next%
- ECHO ============================================================================================================================
- GOTO :EOF
- :::
- :end
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement