def FFRequest(FFQ, RequestStr, LatestTime): #By D@CC #Untested as of 2024BFeb21 #see Article 173 #Runs on a Pi to communicate with #MMBasic on the Pico OrderNumberStr = "BUSY" while OrderNumberStr == "BUSY": #latestTimeWithoutCancellingStr = LatestTime # eg LatestTime=TimeNow+120 "seconds" OrderNumberStr = FFKiosk(FFQ, RequestStr, LatestTime) # FFKiosk will return an OrderNumberStr if OrderNumberStr == "OOS": FFErrorReport("Error: Out Of Service for Request:"+RequestStr) return RequestStr+":OOS" #end if if OrderNumberStr== "BUSY": sleep (2) #sleep 2 seconds #end if # if the while code stops looping, OrderNumberStr will contain an actual number in string format # and the request will have been added to the FFQ. #wend #an order # was returned StatusStr="N" while StatusStr == "N": StatusStr = FFStatus(FFQ, OrderNUmberStr) # returns "N", Not yet complete # "Y" Yes . . . complete # "L" Log of completed orders # or "X" X indicates that the order timed out if StatusStr == "X": FFErrorReport("Error: Cancelled after TimeOut for:"; RequestSt, OrderNumberStr) return RequestStr+":X" #end if if StatusStr == "N": sleep (2) #sleep 2 seconds #end if if StatusStr == "L": FFErrorReport("Warning: Already Read & Logged:"; RequestSt, OrderNumberStr) #end if # while loop stops looping if "L" or "Y" #wend # at this point StatusStr is "L" or "Y" # both cases will return the ResultStr # but the "L" case posted a warning ResultStr = FFResult(FFQ,OrderNumberStr) RequestAndResultStr = RequestStr+":"+ResultStr FFLog(FFQ, OrderNumberStr+":"+RequestAndResultStr) return RequestAndResultStr #end def FFRequest #this code appears in Article 173 #/FFRequest.py