1

Having trouble calling some user input variables (currentWt, height, BMI, which would then be used in this python script below and pasted to clipboard. Is anyone familiar with alfred workflows and knows how I can do this?

import json 
import sys

  print ('Current wt: ') + str({var:currentWt}) + (' lbs (') + str({var:currentWt}/2.2) + (' kg)')
    print ('Height: ') + str({var:height}) + (' inches')


    BMI = ({var:currentWt} / 2.2) / (({var:height} * 0.0254) **2 )


    print ('BMI: ' + str(BMI))

    hamwiMale = (106 + (6 * ({var:height} - 60)))
    hamwiFemale = (105 + (5 * ({var:height} - 60)))

    if {var:gender} == 'Male':
        print ('IBW (calculated using Hamwi): ') + str(hamwiMale)
    elif {var:gender} == 'Female':
        print ('IBW (calculated using Hamwi): ') + str(hamwiFemale)
Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
  • _Having trouble calling some user input variables_ What is the issue? – AMC Nov 08 '20 at 00:43
  • The workflow doesn't recognize any of the variables that I call in the script and says they are undefined, even after assigning them to variables – Cristian Ordonez Nov 08 '20 at 01:27
  • Is there an error message? – AMC Nov 08 '20 at 01:52
  • 1
    [This page](https://www.deanishe.net/post/2018/10/workflow/environment-variables-in-alfred/#python) explains how to use variables inside a Python script in Alfred. You can't use the Alfred syntax, they are instead passed into your script as environment variables. – EpaL May 05 '21 at 00:37

0 Answers0