def access_global_list_definition(): # This must be defined in the pir2A.py # But it can be called from anywhere using # pir2A.access_global_list() global gAL gAL="" gAL=gAL+"."+"g_targTempL0" ; global g_targTempL0 gAL=gAL+"."+"g_gALtest" ; global g_gALtest nCount=2 returnValue = "globalAList was defined containing a global Count of : ",nCount #print("gAL:"+gAL) return returnValue #def end def access_global(gName,AorR,value): # This must be defined in the pir2A.py # It doesn't need to be called from outside the pir2A.py # check if in the gAL (globalAccessList) global gAL gAL1="" gAL1=gAL1+"."+"g_targTempL0" ; global g_targTempL0 gAL1=gAL1+"."+"g_gALtest" ; global g_gALtest nCount=1 #print("in access_global,gAL:"+gAL) #print("gAL:"+gAL) #print("found:", gAL.find(".") ) #print("found:"+gName,gAL.find(gName)) if gAL.find(gName)==-1 : #print("didn't find:"+gName) print("ERROR global Name cannot be accessed:"+gName) returnValue = gName+" ERROR: is not in the globalAccessList!" else: # match/case don't work yet in Python if gName == "g_gALtest": if AorR == "Assign": g_gALtest = value else: returnValue = g_gALtest if gName =="g_targTempL0": if AorR == "Assign": g_targTempL0 = value else: returnValue = g_targTempL0 #if end if AorR=="Assign" : if isTypeStr(value): returnValue=gName+" was assigned value:"+value+":" else: returnValue=gName+" was assigned value:"+str(value)+":" #if end else: continueDoh=1 #if end #if end return returnValue #def end def get_global(gName): global gAL #print("in get_global,gAL:"+gAL) #this is usually called from outside the pir2A.py # it can be called e.g. gALtest = pir2A.get_global("g_gALtest") return access_global(gName,"Retrieve","na") #def end def set_global(gName,value): #print("in set_global, gName:"+gName) #this is usually called from outside the pir2A.py # it can be called e.g. pir2A.set_global("g_gALtest",value) # WARNING: it will over-ride the current value of this global value access_global(gName,"Assign",value) if isTypeStr(value): returnValue= gName+" was set="+value else: returnValue= gName+" was set="+str(value) #doesn't work if value is not a string return returnValue #def end def get_targTempL0(str1): returnValue = access_global("g_targTempL0","Retrieve","na") return returnValue #def end def isTypeStr(vName): Ttype=type(vName) if Ttype=="": return True else: return False #def end #/global_and_isTypeStr.py