parse source . . thisProg
thisProg=filespec("Name", thisProg)

slotDir=arg(arg())
scriptContext=slotDir~scriptContext
GLOBAL_SCOPE=200
url=scriptContext~getAttribute("location",GLOBAL_SCOPE)
fxmlFileName=filespec("name",url~getFile)
dir2obj =.directory~new
.my.app~setEntry(fxmlFileName,dir2obj)
bindings=scriptContext~getBindings(GLOBAL_SCOPE)
keys=bindings~keySet~makearray
do key over keys
   val=bindings~get(key)
   dir2obj ~setEntry(key,val)
end
use arg slotDir
scriptContext = slotDir~scriptContext

parse source s

::routine startWorkout public
    use arg slotDir
    scriptContext = slotDir~scriptContext

         scene2FXMLUrl=.my.app~appClzLdr~findResource("fxml/scene2.fxml")
         scene2FXML   =.my.app~fxmlLoader~load( scene2FXMLUrl )
         .my.app~scene2=.bsf~new("javafx.scene.Scene", scene2FXML)


      .my.app~primaryStage~setScene(.my.app~scene2)
      .my.app~primaryStage~centerOnScreen


/* @get(description muscle) */
      newItems = .my.app~scene2.fxml

      jrnl = description~getText
      if jrnl = "" then do
      say "no journal entry"
       end
       else do
      xDesktop=uno.createDesktop()
               xcl=xDesktop~XComponentLoader
               uri="private:factory/swriter"
               doc=xcl~loadComponentFromURL(uri,"_blank",0,.uno~noProps)
               xText=doc~XTextDocument~getText
               xText~setString(jrnl)
end

mscl = muscle~getValue
newItems~labelMuscle~setText(mscl)
        if muscle~getValue = .nil then do
         mg = ''
         end
         else do
          xDesktop=uno.createDesktop()
                 xcl=xDesktop~XComponentLoader
                 uri="private:factory/scalc"
                 doc=xcl~loadComponentFromURL(uri,"_blank",0,.uno~noProps)
                 xSheets=doc~XSpreadSheetDocument~getSheets~XIndexAccess
                 xSheet =xSheets~getByIndex(0)~XSpreadSheet
                 xSheet~getCellByPosition(1,0)~setFormula("Satz 1")
                 xSheet~getCellByPosition(2,0)~setFormula("Satz 2")
                 xSheet~getCellByPosition(3,0)~setFormula("Satz 3")
                 xSheet~getCellByPosition(4,0)~setFormula("Satz 4")
                 xCols=xSheet~XColumnRowRange~getColumns
                 xCol=xCols~getByIndex(0)
                 props=xCol~XPropertySet

                 oldWidth=props~getPropertyValue("Width")
                 newWidth=oldWidth+1500
                 props~setPropertyValue("Width", box("int",newWidth))

                 xRows=xSheet~XColumnRowRange~getRows
                 xRow=xRows~getByIndex(0)
                 cc=box("int", "06 9a 2e"x ~c2d)
                 props=xRow~XPropertySet
                 props~setPropertyValue("CharColor", cc)

         select
         When mscl = "Brust" Then
         do
                 xSheet~getCellByPosition(0,0)~setFormula(mscl)
                 xSheet~getCellByPosition(0,1)~setFormula("Pushup")
                 xSheet~getCellByPosition(0,2)~setFormula("Benchpress")
                 xSheet~getCellByPosition(0,3)~setFormula("Butterfly")
                 xSheet~getCellByPosition(0,4)~setFormula("Incline Barbell Press")
                 xSheet~getCellByPosition(0,5)~setFormula("Decline Press")
                 xSheet~getCellByPosition(1,6)~setFormula("https://www.menshealth.com/fitness/a19545838/10-best-back-exercises/")


                 end
         When mscl = "Rucken" Then
         do
                xSheet~getCellByPosition(0,0)~setFormula(mscl)
                xSheet~getCellByPosition(0,1)~setFormula("Chin ups")
                xSheet~getCellByPosition(0,2)~setFormula("Deadlift")
                xSheet~getCellByPosition(0,3)~setFormula("Barbell Rows")
                xSheet~getCellByPosition(0,4)~setFormula("Cable Row")
                xSheet~getCellByPosition(0,5)~setFormula("Lat Pulldown")
         end
         When mscl = "Beine" Then
                  do
                         xSheet~getCellByPosition(0,0)~setFormula(mscl)
                         xSheet~getCellByPosition(0,1)~setFormula("Kniebeugen")
                         xSheet~getCellByPosition(0,2)~setFormula("Beinpresse")
                         xSheet~getCellByPosition(0,3)~setFormula("Leg extensions")
                         xSheet~getCellByPosition(0,4)~setFormula("Leg curls")
                         xSheet~getCellByPosition(0,5)~setFormula("calv raises")
                  end
         When mscl = "Schultern" Then
                   do
                   xSheet~getCellByPosition(0,0)~setFormula(mscl)
                   xSheet~getCellByPosition(0,1)~setFormula("Overhead press")
                   xSheet~getCellByPosition(0,2)~setFormula("Lateral raises")
                   xSheet~getCellByPosition(0,3)~setFormula("Reverse Butterfly")
                   xSheet~getCellByPosition(0,4)~setFormula("Front raise")

                   end
         When mscl = "Arme" Then
                                      do
                                      xSheet~getCellByPosition(0,0)~setFormula(mscl)
                                      xSheet~getCellByPosition(0,1)~setFormula("Dips")
                                      xSheet~getCellByPosition(0,2)~setFormula("Cable Triceps Extension")
                                      xSheet~getCellByPosition(0,3)~setFormula("Bicep Curls")
                                      xSheet~getCellByPosition(0,4)~setFormula("Hammer Curls")

                                      end
         When mscl = "Bauch" Then
                                      do
                                      xSheet~getCellByPosition(0,0)~setFormula(mscl)
                                      xSheet~getCellByPosition(0,1)~setFormula("Crunches")
                                      xSheet~getCellByPosition(0,2)~setFormula("Side Plank")
                                      xSheet~getCellByPosition(0,3)~setFormula("Russian Twist")
                                      xSheet~getCellByPosition(0,4)~setFormula("Leg Raises")

                                      end
         When mscl = "Laufen" Then
                                               do
                                               xSheet~getCellByPosition(0,0)~setFormula(mscl)
                                               xSheet~getCellByPosition(0,1)~setFormula("Zeit Runde 1:")
                                               xSheet~getCellByPosition(0,2)~setFormula("Zeit Runde 2:")
                                               xSheet~getCellByPosition(0,3)~setFormula("Zeit Runde 3")
                                               xSheet~getCellByPosition(0,4)~setFormula("Zeit Runde 4")

                                               end
         When mscl = "Radeln" Then
                                               do
                                               xSheet~getCellByPosition(0,0)~setFormula(mscl)
                                               xSheet~getCellByPosition(0,1)~setFormula("Distance (km):")
                                               xSheet~getCellByPosition(0,2)~setFormula("Höhenmeter:")
                                               xSheet~getCellByPosition(0,3)~setFormula("Zeit:")
                                               xSheet~getCellByPosition(0,4)~setFormula("Watt")

                                               end
         When mscl = "Rudern" Then
                                               do
                                               xSheet~getCellByPosition(0,0)~setFormula(mscl)
                                               xSheet~getCellByPosition(0,1)~setFormula("Distance (km):")
                                               xSheet~getCellByPosition(0,2)~setFormula("Average Speed:")
                                               xSheet~getCellByPosition(0,3)~setFormula("Time:")
                                               xSheet~getCellByPosition(0,4)~setFormula("Kcal")

                                               end

end

         end


::requires UNO.CLS
::routine backButton public
use arg slotDir
scriptContext=slotDir~scriptContext
.my.app~primaryStage~setScene(.my.app~mainScene)
::routine weitereLinks public

    Desktop = bsf.loadClass("java.awt.Desktop")~getDesktop
    url="https://builtwithscience.com/best-full-body-workout/"
    uri = .bsf~new("java.net.URI", url)
    Desktop~browse(uri)
::routine endWorkoutbutton public
.my.app~primaryStage~close
