Advertisement
GlobalAccessSoftware

runtime_display.bat

Nov 16th, 2023
987
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 13.13 KB | Software | 0 0
  1.  
  2.  
  3. ::: RC8 Update! :::
  4.  
  5. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  6. ::: Split out from SyncOlderPhotos.bat Sept 8th, 2022   :::
  7. ::: For reUsages with other things. see set vars below. :::
  8. ::: set vers=v7.9.7.64 20221104054808 by -JpE-          :::
  9. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  10. :::   Runtime Display Module Copyright 2023 by -JpE-    :::
  11. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  12.  
  13. ::: <These vars must be set:>
  14. ::: set timethen=%time%
  15. ::: set datethen=%date%
  16. ::: <ASSURE ^ THESE ARE SET IN START OF ALL CALLERS!>
  17.  
  18.   set /a test21=(1)
  19.  
  20.   rem Have made untested changes that could fix it. 783 ???
  21.  
  22. REM Seems to be a bug at Zulu hour, double zeros or such. It begins to manifest between Pause 1 and 2 with missing operator or something, then between 4 and 4b maybe as soon as 4a, then it becomes fatal somewhere after 8 and 9 somewhere which crashes the program until the bad or zulu numbers don't appear anymore. Once the missing operator (or whatever err that is) goes away, (time has passed) then it goes away and everything works fine again. Zulu hour definetly suspect, but unconfirmed. Check into the logic there. It might be as simple as replacing a " " or "" with a "0" or zero. (without the quotes)
  23.  
  24.   ::: Set test21 ^ to 7 for trace mode, else it's off.
  25.   if not defined vers set vers=v8.7.0.09 20231106063912 by -JpE-
  26.  
  27. :runtime
  28.   echo    %sl%
  29.   echo                  Runtime Display Ultra Pro Deluxe 8
  30.   echo    %sl%
  31.   echo                 %vers%
  32.   echo    %sl%
  33.   echo .
  34.   echo **%l1%**
  35.   set calcdate=%date%
  36.   set calctime=%time%
  37.  
  38.   ::: =====================[ NOW BEGIN ]=====================
  39.   set "yearnow=%date:~0,4%"
  40.   set /a yrn=(%yearnow%)
  41.  :::
  42.   set "montnow=%date:~5,2%"
  43.   if "%montnow:~0,1%" equ " " set montnow=%montnow:~1,1%
  44.   if "%montnow:~0,1%" equ "0" set montnow=%montnow:~1,1%
  45.   if "%montnow%" equ "" set montnow=0
  46.   set /a mtn=(%montnow%)
  47.  :::
  48.   set "daysnow=%date:~8,2%"
  49.   if "%daysnow:~0,1%" equ " " set daysnow=%daysnow:~1,1%
  50.   if "%daysnow:~0,1%" equ "0" set daysnow=%daysnow:~1,1%
  51.   if "%daysnow%" equ "" set daysnow=0
  52.   set /a dyn=(%daysnow%)  
  53.   if %test21% == 7 echo . & echo pause-1 & echo . & pause & echo .
  54.  
  55.  
  56.   :::::::::::::::::::::::::::::::::
  57.  ::: Hours | Minutes | Seconds :::
  58.  :::::::::::::::::::::::::::::::::  
  59.  REM Tracking Zulu Hour Bugs... I think I got it v85!
  60.   set "hournow=%time:~0,2%"
  61.   if "%hournow:~0,1%" equ " " set hournow=%hournow:~1,1%
  62.   if "%hournow:~0,1%" equ "0" set hournow=%hournow:~1,1%
  63. REM echo hournow == %hournow% & pause
  64.   if "%hournow:~1,1%" equ " " set hournow="0"
  65.     if "%hournow%" equ "" set hournow=0
  66.   set /a hrn=(%hournow%)
  67. REM echo hournow == %hournow%, hrn == %hrn% & pause
  68.  :::
  69.   if %test21% == 7 echo . & echo pause-2 & echo . & pause & echo .
  70.   set "minsnow=%time:~3,2%"
  71.   if "%minsnow:~0,1%" equ " " set minsnow=%minsnow:~1,1%
  72.   if "%minsnow:~0,1%" equ "0" set minsnow=%minsnow:~1,1%
  73.   if "%minsnow:~1,1%" equ " " set minsnow="0"
  74.     if "%minsnow%" equ "" set minsnow=0
  75.   set /a min=(%minsnow%)
  76.  :::
  77.   if %test21% == 7 echo . & echo pause-2a & echo . & pause & echo .
  78.   set "secsnow=%time:~6,2%"
  79.   if "%secsnow:~0,1%" equ " " set secsnow=%secsnow:~1,1%
  80.   if "%secsnow:~0,1%" equ "0" set secsnow=%secsnow:~1,1%
  81.   if "%secsnow:~1,1%" equ " " set secsnow="0"
  82.     if "%secsnow%" equ "" set secsnow=0
  83.   set /a scn=(%secsnow%)
  84.  :::
  85.   if %test21% == 7 echo . & echo pause-2b & echo . & pause & echo .
  86.   set "centinow=%time:~9,2%"
  87.   if "%centinow:~0,1%" equ " " set centinow=%centinow:~1,1%
  88.   if "%centinow:~0,1%" equ "0" set centinow=%centinow:~1,1%
  89.   if "%centinow:~1,1%" equ " " set centinow="0"
  90.     if "%centinow%" equ "" set centinow=0
  91.   set /a mln=(%centinow%)
  92.   if %test21% == 7 echo . & echo pause-3 & echo . & pause & echo .
  93.  
  94.  
  95.   ::: =====================[ NOW END ]=====================
  96.  :::       SUPER-PARSER DELUXE : PARSING EXAMPLE
  97.  ::: =====================================================
  98.  
  99.   ::::::::::::::::::::::::[ THEN BEGIN ]:::::::::::::::::::::
  100.   set "yearthen=%datethen:~0,4%"
  101.   set /a yrt=(%yearthen%)
  102.  :::
  103.   set "montthen=%datethen:~5,2%"
  104.   if "%montthen:~0,1%" equ " " set montthen=%montthen:~1,1%
  105.   if "%montthen:~0,1%" equ "0" set montthen=%montthen:~1,1%
  106.   if "%montthen%" equ "" set montthen=0
  107.   set /a mtt=(%montthen%)
  108.   if %test21% == 7 echo . & echo pause-4 & echo . & pause & echo .
  109.  :::
  110.   set "daysthen=%datethen:~8,2%"
  111.   if "%daysthen:~0,1%" equ " " set daysthen=%daysthen:~1,1%
  112.   if "%daysthen:~0,1%" equ "0" set daysthen=%daysthen:~1,1%
  113.   if "%daysthen%" equ "" set daysthen=0
  114.   set /a dyt=(%daysthen%)
  115.   if %test21% == 7 echo . & echo pause-4a & echo . & pause & echo .
  116.  :::
  117.   set "hourthen=%timethen:~0,2%"
  118.   if "%hourthen:~0,1%" equ " " set hourthen=%hourthen:~1,1%
  119.   if "%hourthen:~0,1%" equ "0" set hourthen=%hourthen:~1,1%
  120.   if "%hourthen:~1,1%" equ " " set hourthen="0"
  121.   if "%hourthen%" equ "" set hourthen=0
  122.   set /a hrt=(%hourthen%)  
  123.   if %test21% == 7 echo . & echo pause-5 & echo . & pause & echo .
  124.  :::
  125.   set "minsthen=%timethen:~3,2%"
  126.   if "%minsthen:~0,1%" equ " " set minsthen=%minsthen:~1,1%
  127.   if "%minsthen:~0,1%" equ "0" set minsthen=%minsthen:~1,1%
  128.   if "%minsthen:~1,1%" equ " " set minsthen="0"
  129.   if "%minsthen%" equ "" set minsthen=0
  130.   set /a mit=(%minsthen%)
  131.  :::
  132.   set "secsthen=%timethen:~6,2%"
  133.   if "%secsthen:~0,1%" equ " " set secsthen=%secsthen:~1,1%
  134.   if "%secsthen:~0,1%" equ "0" set secsthen=%secsthen:~1,1%
  135.   if "%secsthen:~1,1%" equ " " set secsthen="0"
  136.   if "%secsthen%" equ "" set secsthen=0
  137.   set /a sct=(%secsthen%)
  138.  :::
  139.   set "centithen=%timethen:~9,2%"
  140.   if "%centithen:~0,1%" equ " " set centithen=%centithen:~1,1%
  141.   if "%centithen:~0,1%" equ "0" set centithen=%centithen:~1,1%
  142.   if "%centithen:~1,1%" equ " " set centithen="0"
  143.   if "%centinow%" equ "" set centinow=0
  144.   set /a mlt=(%centithen%)
  145.  ::::::::::::::::::::::::[ THEN END ]:::::::::::::::::::::
  146.  
  147.  
  148.   ::::::::::::::::::::::::::::::::::::::::::::
  149.  ::: Days In Month aka dim, I know right. :::
  150.  ::::::::::::::::::::::::::::::::::::::::::::
  151.   set /a day=365
  152.   set /a "mod=%yrn% %% 4%"
  153.   if %mod% equ 0 set /a day=366
  154.   set /a dim=31
  155.   if %mtn% neq 2 goto notfeb
  156.  
  157.   ::: February regular or Leap Year!
  158.   set /a dim=28
  159.   if %mod% equ 0 set /a dim=29
  160.  
  161. :notfeb
  162.  ::: 30 days hath September, April, June, && November!!!
  163.  ::: (all the rest have 31, except for february which
  164.  ::: has 28, unless the year / 4 == whole-number,
  165.  ::: in which case it's leap year & Feb has 29 days! (above) -ed
  166.   if %mtn% equ 9 set /a dim=30
  167.   if %mtn% equ 4 set /a dim=30
  168.   if %mtn% equ 6 set /a dim=30
  169.   if %mtn% equ 11 set /a dim=30
  170.  
  171.   :::::::::::::::::::::
  172.  ::: Month as Word :::
  173.  :::::::::::::::::::::
  174.   set mt=January
  175.   if %mtn% equ 2 set mt=February
  176.   if %mtn% equ 3 set mt=March
  177.   if %mtn% equ 4 set mt=April
  178.   if %mtn% equ 5 set mt=May
  179.   if %mtn% equ 6 set mt=June
  180.   if %mtn% equ 7 set mt=July
  181.   if %mtn% equ 8 set mt=August
  182.   if %mtn% equ 9 set mt=September
  183.   if %mtn% equ 10 set mt=October
  184.   if %mtn% equ 11 set mt=November
  185.   if %mtn% equ 12 set mt=December
  186.  
  187.  
  188.   :::::::::::::::::::::::::::::::
  189.  ::: Day of Week as a Word:  :::
  190.  :::::::::::::::::::::::::::::::
  191.   set util2="%bats%\utility2.bat"
  192.   if exist %util2% call %util2% dayOfWeek
  193.  ::: Mod 20230718030330 v8.5.6.77 :::
  194.  ::::::::::::::::::::::::::::::::::::
  195.   if %test21% == 7 echo . & echo pause-6 & echo . & pause & echo .
  196.  
  197.  
  198.   ::::::::::::::::::::::::::::::::::::
  199.  ::: Partial Duplicate to Screen. :::
  200.  ::::::::::::::::::::::::::::::::::::
  201.   set ext=th
  202.   set ned=th
  203.   if %dyn% == 1 set ned=st
  204.   if %dyn% == 21 set ned=st
  205.   if %dyn% == 31 set ned=st
  206.   if %mtn% == 1 set ext=st
  207.   if %dyn% == 2 set ned=nd
  208.   if %dyn% == 22 set ned=nd
  209.   if %mtn% == 2 set ext=nd
  210.   if %dyn% == 3 set ned=rd
  211.   if %dyn% == 23 set ned=rd
  212.   if %mtn% == 3 set ext=rd
  213.   if %mod% == 0 set msg=IT'S LEAPYEAR!
  214.  
  215.   if %test21% == 7 echo . & echo pause-7 & echo . & pause & echo .
  216.  
  217.   ::: !!! R3 mods !!!
  218.   set mlclc=%calctime:~9,2%
  219.   if "%mlclc:~0,1%" equ " " set mlclc=%mlclc:~1,1%
  220.   if "%mlclc:~0,1%" equ "0" set mlclc=%mlclc:~1,1%
  221.   set /a mlclc=(%mlclc%)
  222.   set nowtime=%time%
  223.  :::  ^ for syncronization precision below.
  224.  
  225.   ::: strings to numbers...
  226.   set mlnow=%nowtime:~9,2%
  227.   if "%mlnow:~0,1%" equ " " set mlnow=%mlnow:~1,1%
  228.   if "%mlnow:~0,1%" equ "0" set mlnow=%mlnow:~1,1%
  229.   set /a mlnow=(%mlnow%)
  230.  
  231.   ::: Now Do the numerical calculations...
  232.   set /a rtp=(%mlnow%-%mlclc%)
  233.   if %rtp% lss 0 set /a rtp+=100
  234.  ::: add -num is subtraction ^
  235.  
  236.   ::: Then our new numbers go back to padded strings!
  237.   set rtpt=%rtp%
  238.   if %rtp% leq 9 set "rtpt=0%rtpt%"
  239.  
  240.   ::: To display.
  241.   echo **%sl%         **
  242.   echo **%l1%**
  243.  
  244.   ::: !!! revised RC8-v8.5.6.80 mods CONDENSED - REUSABLE !!!
  245.   set strlen="%bats%\string_length.bat"
  246.   set pads="%bats%\add_padding.bat"
  247.  ::: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  248.   set line=It's %dayOfWeek% %mt% %daysnow%%ned%, %yearnow% @ %nowtime%
  249.   if exist %pads% if exist %strlen% call %pads%
  250.   echo **      %line%**
  251.   if %test21% == 7 echo . & echo pause-8 & echo . & pause & echo .
  252.  ::: ^v extended uses of set line=bla & call %pads%
  253.  
  254.   set line=Processing Time was: 0.%rtpt% seconds on this System!
  255.   if exist %pads% if exist %strlen% call %pads%
  256.   echo **      %line%**
  257.   echo **%l1%**
  258.   if %test21% == 7 echo . & echo pause-9 & echo . & pause & echo .
  259.  :::
  260.   set line=Program Started: %datethen% @ %timethen%
  261.   if exist %pads% if exist %strlen% call %pads%
  262.   echo **      %line%**
  263.  :::
  264.   set line=Program Finish:  %calcdate% @ %calctime%
  265.   if exist %pads% if exist %strlen% call %pads%
  266.   echo **      %line%**
  267.   echo **%l1%**
  268.  :::
  269.   set line=%mt% is the %mtn%%ext% month. %mt% has %dim% days.
  270.   if exist %pads% if exist %strlen% call %pads%
  271.   echo **      %line%**
  272.  :::
  273.  REM if %test21% == 7 echo . & echo pause-9v & echo . & pause & echo .
  274.   if %mod% equ 0 set line=%msg% & if exist %pads% if exist %strlen% call %pads% & echo **%l1%** & echo **      %line%**
  275.   if %test21% == 7 echo . & echo pause-10 & echo . & pause & echo .
  276.  ::: end R8 mods
  277.  
  278.  
  279.   :::::::::::::::::::::::::::::::::::::
  280.  :: Calculate how long it has been. ::
  281.  :::::::::::::::::::::::::::::::::::::
  282.   set /a centi=(%mln%-%mlt%)
  283.   if %centi% lss 0 set /a scn-=1 & set /a "centi=(100+%centi%)"
  284.  
  285.   set /a secs=(%scn%-%sct%)
  286.   if %secs% lss 0 set /a min-=1 & set /a "secs=(60+%secs%)"
  287.  
  288.   set /a mins=(%min%-%mit%)
  289.   if %mins% lss 0 set /a hrn-=1 & set /a "mins=(60+%mins%)"
  290.  
  291.   set /a hour=(%hrn%-%hrt%)
  292.   if %hour% lss 0 set /a dyn-=1 & set /a "hour=(24+%hour%)"
  293.  
  294.   set /a days=(%dyn%-%dyt%)
  295.   if %days% lss 0 set /a mtn-=1 & set /a "days=(%dim%+%days%)"
  296.  
  297.   set /a mnth=(%mtn%-%mtt%)
  298.   if %mnth% lss 0 set /a yrn-=1 & set /a "mnth=(12+%mnth%)"
  299.  
  300.   set /a year=(%yrn%-%yrt%)
  301.   if %year% lss 0 set /a "year=0"
  302.  
  303.   if %test21% == 7 echo . & echo pause-11 & echo . & pause & echo .
  304.  
  305.  
  306.   ::::::::::::::::::::::::::::::::::
  307.  :: Check all values and Pad text
  308.  ::::::::::::::::::::::::::::::::::
  309.   if %year% lss 0 goto err
  310.  
  311.   set yrs=%year%
  312.   if %year% lss 10 set yrs=0%year%
  313.  ::
  314.   if %mnth% lss 0 goto err
  315.   if %mnth% gtr 12 goto err
  316.  
  317.   if %test21% == 7 echo . & echo pause-12 & echo . & pause & echo .
  318.  
  319.   set mts=%mnth%
  320.   if %mnth% lss 10 set mts=0%mnth%
  321.  ::
  322.   if %days% lss 0 goto err
  323.   if %days% gtr %dim% goto err
  324.  
  325.   set dys=%days%
  326.   if %days% lss 10 set dys=0%days%
  327.  ::
  328.   if %hour% lss 0 goto err
  329.   if %hour% gtr 23 goto err
  330.  
  331.   set hrs=%hour%
  332.   if %hour% lss 10 set hrs=0%hour%
  333.  ::
  334.   if %mins% lss 0 goto err
  335.   if %mins% gtr 59 goto err
  336.  
  337.   if %test21% == 7 echo . & echo pause-13 & echo . & pause & echo .
  338.  
  339.   set mns=%mins%
  340.   if %mins% lss 10 set mns=0%mins%
  341.  ::
  342.   if %secs% lss 0 goto err
  343.   if %secs% gtr 59 goto err
  344.  
  345.   set scs=%secs%
  346.   if %secs% lss 10 set scs=0%secs%
  347.  ::
  348.   if %centi% lss 0 goto err
  349.   if %centi% gtr 99 goto err
  350.  
  351.   set mli=%centi%
  352.   if %centi% lss 10 set mli=0%centi%
  353.  
  354.   if %test21% == 7 echo . & echo pause-14 & echo . & pause & echo .
  355.  
  356.   ::::::::::::::::::::
  357.  :: Log Code 7     ::
  358.  ::::::::::::::::::::
  359.  :: RESULTS CHECK  ::
  360.  ::::::::::::::::::::
  361.   echo **%l1%**
  362.   set line=Runtime Calculated with RunT-8.7.1
  363.   if exist %pads% if exist %strlen% call %pads%
  364.   echo **      %line%**
  365.   set line= ==================================
  366.   if exist %pads% if exist %strlen% call %pads%
  367.   echo **     %line% **
  368.   set line=%yrs% years, %mts% months,  %dys% days,
  369.   if exist %pads% if exist %strlen% call %pads%
  370.   echo **      %line%**
  371.   set line=%hrs% hours, %mns% minutes, %scs%.%mli% seconds.
  372.   if exist %pads% if exist %strlen% call %pads%
  373.   echo **      %line%**
  374.   echo **%l1%**
  375.   set line=Bye Bye For Now! Fare Well. Come Again. Adios!
  376.   if exist %pads% if exist %strlen% call %pads%
  377.   echo **      %line%**
  378.   echo **%l1%**
  379.   echo .
  380.   goto return
  381.  
  382. :err
  383.   echo **%l2%**
  384.   set line=Error Detected, Please Review it.
  385.   if exist %pads% if exist %strlen% call %pads%
  386.   echo **      %line%**
  387.   echo **%l2%**
  388.  :: Programmatic pause for beta test user action.
  389.   pause
  390.   echo %l2%
  391.  
  392. :return
  393.   if %test21% == 7 echo Pause-END & pause
  394.   exit /b %errorlevel%
  395.  
  396.  
  397.  
  398.   ::: 100% -JpE-
  399.  
  400.  
  401.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement