Guest User

Untitled

a guest
Apr 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. /**********************************************************************************
  2. queryByFormula
  3.  
  4. $inTable -> Table pointer Table to apply query
  5. $inExpression -> Text Expression to execute for each record,
  6. should evaluate to a boolean
  7. $context -> Collection Values for use in the expression
  8.  
  9. Allows you to execute a QUERY BY FORMULA using Active4D variables
  10. and methods. This is the functional equivalent of the QUERY BY FORMULA
  11. command from v4.5.
  12.  
  13. If $inExpression is empty, the current selection of $inTable will be empty.
  14. **********************************************************************************/
  15.  
  16. method "queryByFormula"($inTable; $inExpression; $context = 0)
  17.  
  18. if (length($inExpression) # 0)
  19. $inExpression := "return ({0})" %% ($inExpression)
  20. all records($inTable->)
  21. $set := "a4d.utils.queryByFormula"
  22. create empty set($inTable->; $set)
  23.  
  24. for each($inTable->)
  25. if (execute($inExpression))
  26. add to set($inTable->; $set)
  27. end if
  28. end for each
  29.  
  30. use set($set)
  31. clear set($set)
  32. first record($inTable->)
  33. else
  34. reduce selection($inTable->; 0)
  35. end if
  36.  
  37. end method
Add Comment
Please, Sign In to add comment