码迷,mamicode.com
首页 > 其他好文 > 详细

Project Siena - 函数

时间:2015-01-26 16:46:41      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:

Project Siena内置了很多函数,帮助我们实现常规操作,其中

  1. 绝对值
    Abs(Number)
    Abs(ColumnExpression)
    如:
    Abs(-12) = 12

  2. 逻辑与
    And(LogicalExpression1[, LogicalExpression2, ...])
    如:
    And(3>1,3>2,3>3) = false

  3. 平均值
    Average(Table, Expression)
    Average(Expression1[, Expression2, …])
    如:
    Average(Sales,CostPerUnit * UnitsSold),Average(1,2,3,4)= 2.5

  4. 将数字转换成ASCII编码的字符
    Char(Number)
    如:
    Char(97) = ‘a‘

  5. 清空集合
    Clear(Collection)

  6. 创建集合
    Collect(CollectionName, Item1[, Item2,...])
    如:
    Collect(CollectionName,TableName)
    Collect(CollectionName,TableName!ColumnName)
    Collect(Products, "violins", "trombones", "bongos")
    Collect(CollectionName,ControlName1!Value,ControlName2!Value,ControlNameN!Value)
    Collect(OrderHistory, {Products:Product!Text, Quantities:Quantity!Text})

  7. 颜色淡出
    ColorFade(Color, FadeDelta)
    如:
    ColorFade(Color!DarkRed,0.5)

  8. 字符串转颜色
    ColorValue(ColorText)

    如:
    ColorValue(TextMessage!Text)

  9. 拼接字符串
    Concatenate(Text1[, Text2, ...])
    Concatenate(ColumnExpression1[, ColumnExpression2, ...])
    如:
    Concatenate("By ", AuthorName!Text)
    Concatenate(Employees!FirstName, " ", Employees!LastName)

  10. 计数(注意:按照某一列进行计数)
    Count
    (Column)
    如:
    Count(Value(OrderHistory!Quantities))

  11. 非空计数
    CountA
    (Column)

  12. 条件计数
    CountIf
    (Table, Expression)
    如:
    CountIf(Employees, Salary > 100000)

  13. 行号
    CountRows
    (Table)
    如:
    CountRows(Employees)

  14. 获取日期
    Date
    (Year, Month, Day)
    如:
    Date(2015,03,15)

  15. 添加日期
    DateAdd
    (Date, NumberOfUnits[, Units])
    如:
    DateAdd(Now(), 3)
    DateAdd(Today(), 1, Days)
    DateAdd(Today(), 1, Months)

  16. 时间间隔
    DateDiff
    (StartDate, EndDate[, Units])
    如:
    DateDiff(Now(), 1/1/2014)
    DateDiff(Now(), 1/1/2014, Months)

  17. 格式化时间
    DateTimeValue (DateTimeText, "LanguageCode")
    如:
    Text(DateTimeValue(Start!Text), DateTimeFormat!LongDateTime)
    Text(DateTimeValue(Start!Text, "fr"), DateTimeFormat!LongDateTime)
    Text(DateTimeValue(Start!Text), "dddd, mmmm dd, yyyy hh:mm:ss:ff AM/PM")
  18. 字符串转日期格式
    DateValue (
    DateText, "LanguageCode")
    如:
    Text(DateValue(Startdate!Text), DateTimeFormat!LongDate)
    DateDiff(DateValue(Startdate!Text), Today())

  19. 获取日期
    Day(DateTime)

  20. 获取小时
    Hour(DateTime)

  21. 禁用功能
    Disable
    (Signal)
    如:
    Disable(Location)

  22. 启用功能
    Enable(Signal)
    如:
    Enable(Location)

  23. 消除冗余项
    Distinct(Table, Expression)
    如:
    Distinct(Employees, Department)

  24. 删除某列
    DropColumns(Table, Column1[, Column2, …])
    如:
    DropColumns(Employees, "FirstName", "LastName", "Address")

  25. 添加某列
    AddColumns(Table, Column1, Expression1[, Column2, Expression2, ...])
    如:
    Collect(Items,AddColumns(Sales,"TotalPrice",UnitsSold*UnitsSold))

  26. URL地址编码
    EncodeUrl
    (Text)
    如:
    EncodeUrl("‘http://example/page/url.aspx") = %27http%3A%2F%2Fexample%2Fpage%2Furl.aspx

  27. 过滤数据
    Filter
    (Table, Condition1[, Condition2, ...])
    如:
    Filter(Employees, Salary > 100000)

  28. 查找文本
    Find(FindText, WithinText[, StartNum])
    如:
    Find("me", "time") = 3
    Find("my", "time") = nothing
    Find("in", "Honorificabilitudinitatibus", 4) = 18
    Find("in", "Honorificabilitudinitatibus", 19) = nothing

  29. 返回集合中第一个元素
    First(Table)

  30. 返回指定数量的行数
    FirstN(Table[, NumRows])
    如:
    FirstN(Employees, 10)

  31. 根据#返回hashtable
    HashTags(Text)
    如:
    字符串:This #app is #AMAZING and can #coUnt123 or #123abc but not #1-23 or #$*(#@")
    HashTags(字符串) =
    • #app

    • #AMAZING

    • #coUnt123

    • #123abc

    • #1

  32. 分支选择
    If(Condition1, Result1[, Condition2, Result2, ConditionN, ResultN, DefaultResult])
    如:
    If(MyShare!Value + YourShare!Value < 100, "Not enough", MyShare!Value + YourShare!Value > 100, "Too much", "Just right")
    If(Value(ThisItem!Quantities) < 5, "Order more!")

  33. 空白判断
    IsBlank(Expression)
    如:
    If(IsBlank(Quantity!Text), "Please add a quantity.")
  34. 集合为空
    IsEmpty(Source)
    如:
    IsEmpty(Employees)
  35. 获取本地语言
    Language()
    如:
    Language() = en-US
  36. 获取集合最后一个对象
    Last(Table)
    如:
    Last(Employees)
  37. 获取指定数量的后几条记录
    LastN(Table[, NumRows])
    如:
    LastN(Employees, 15)
  38. 跳转地址
    Launch(Hyperlink)
    如:
    Launch("http://www.bing.com")
  39. 左截取
    Left(Text, NumChars)
    Left(ColumnExpression, NumericExpression)
    如:
    Left(PhoneNumber!Text, 3)
    Left(ThisItem!Products, 3)
  40. 获取文本长度
    Len(Text)
    Len(ColumnExpression)
    如:
    Len(Password!Text)
  41. 加载数据
    LoadData(Collection, Filename)
    如:
    LoadData(OrderHistory, "SavedOrders")
  42. 在表中条件查询
    LookUp(Table, Condition, Expression)
    如:
    LookUp(Employees, FirstName = "John" && LastName = "Smith", Salary)
  43. 转小写
    Lower(Text)
    Lower(ColumnExpression)
    如:
    Lower(Poetry!Text)
    Lower(ThisItem!Product)
  44. 获取最大值
    Max(Table, Expression)
    Max(Expression1[, Expression2, ...])
    如:
    Max(Sales, CostPerUnit * UnitsSold)
    Max(Slider1!Value, Slider2!Value, Slider3!Value)
  45. 截取字符串
    Mid(Text, StartPosition, NumChars)
    Mid(TextColumn, StartPositions, NumChars)
    如:
    Mid(PhoneNumber!Text, 3, 3)
    Mid(ThisItem!Product, 4, 3)
  46. 获取最小值
    Min(Table, Expression)
    Min(Expression1[, Expression2, ...])
    如:
    Min(Sales, CostPerUnit * UnitsSold)
    Min(Slider1!Value, Slider2!Value, Slider3!Value)
  47. 获取分钟
    Minute(DateTime)
    如:
    Minute(TimeValue(EventTime!Text))
  48. 获取月份
    Month(DateTime)
    如:
    Month(DateValue("03/17/1979"))
  49. 场景跳转
    Navigate(TargetScreen, Animation[, Context])
    如:
    Navigate(DetailView, ScreenTransition!Fade, {source: "Ravens"})
    Navigate(DetailView, ScreenTransition!Fade)
    Navigate(DetailView, "")
  50. 取反
    Not(BooleanExpression)
    如:
    Not(RadioButton1!Selected)
  51. 获取当前时间
    Now()
    如:
    Text(Now(), "mm/dd/yyyy hh:mm:ss:ff")
  52. 逻辑或
    Or(LogicalExpression1[, LogicalExpression2, ...])
    如:
    Or(Slider1!Value < 50, Slider1!Value> 100)
    Or(Dept = HR, Salary >= 200000)
  53. 返回纯文本
    PlainText(TextWithTags)
    如:
    PlainText(ThisItem!description)
  54. 首字母大写
    Proper(Text)
    Proper(ColumnExpression)
  55. 获取随机数
    Rand()
  56. 刷新数据源
    Refresh(ServiceDataSource)
  57. 移除数据源
    Remove(Collection, Record1[, Record2, ..., All])
    Remove(Collection, Table[, All])
    如:
    Remove(OrderHistory, ThisItem)
  58. 根据条件移除数据源
    RemoveIf(Collection, Condition1[, Condition2 ...])
    如:
    RemoveIf(Cart, Price > 200)
  59. 文本替换
    Replace(Text, StartIndex, Count, NewText)
    Replace(Column, StartIndex, Count, NewText)
    如:
    Replace("ABCDEFG", 3, 2, "X") = ABXEFG
  60. 返回颜色
    RGBA(Red, Green, Blue, Alpha)
    如:
    RGBA(255, 127, 39, 1)
  61. 右截取
    Right(Text, NumChars)
    Right(ColumnExpression, NumericExpression)
    如:
    Right("ABCDE", 4)
  62. 四舍五入
    Round(Number, DecimalPlaces)
    Round(Column, DecimalPlaces)
  63. 向下取整
    RoundDown(Number, DecimalPlaces)
    RoundDown(Column, DecimalPlaces)
    如:
    RoundDown(23.54, 0) = 23
  64. 向上取整
    RoundUp(Number, DecimalPlaces)
    RoundUp(Column, DecimalPlaces)
    如:
    RoundUp(23.44, 1) = 23.5
  65. 保存数据
    SaveData(Collection, FileName)
    如:
    Collect(OrderHistory, {Products:Product!Text, Quantities:Quantity!Text});
    SaveData(OrderHistory, "SavedOrders")
  66. 获取秒
    Second(DateTime)
    如:
    Second(TimeValue(EventTime!Text))
  67. 重新排列集合
    Shuffle(Collection)
    如:
    Shuffle(Deck)
  68. 排序集合
    Sort(Table, Expression[, SortOrder!Descending])
    如:
    Sort(Employees, Salary, SortOrder!Descending)
  69. 平方根
    Sqrt(Number)
    Sqrt(ColumnExpression1)
    如:
    Sqrt(2) = 1.414
  70. 标准方差
    StdevP(Table,Expression)
    StdevP(Expression1[,Expression2, ...])
  71. 字符串替换
    Substitute(Text, OldText, NewText[,InstanceNum])
    Substitute(TextColumn, OldTextColumn, NewTextColumn[, InstanceNumColumn])
    如:
    Substitute(Text1!Text, " & ", " and ")
  72. 求和
    Sum(Table, Expression)
    Sum(Expression1[, Expression2, ...])
  73. 格式化文本
    Text(Value, Format)
    如:
    Text(Value(Source!Text), "$#.##") = $56.75
    Text(Value(Source!Text), "#.##%") = 56.75%
    Text(DateValue(Source!Text), "mmm dd, yyyy") = May 18, 1969
    Text(TimeValue(Source!Text), "hh:mm:ss") = 2:20:30 PM
  74. 获取时间
    Time(Hour, Minute, Second)
    如:
    Text(Time(Value(BirthHour!Text), Value(BirthMinute!Text), Value(BirthSecond!Text)), "hh:mm:ss a/p")
  75. 字符串转时间
    TimeValue(TimeText)
    TimeValue(TimeText, "LanguageCode")
    如:
    If(TimeValue(FinishedAt!Text)<TimeValue("5:00:00.000 PM"), "You made it!", "Too late!")
  76. 获取今天的日期(不包含时分秒)
    Today()
    如:
    Text(Today(), "mm/dd/yyyy")
  77. 截取多余空格
    Trim(Text)
    Trim(ColumnExpression)
    如:
    Trim(Slogan!Text)
  78. 更新数据
    Update(Collection, Record1, Record2[, "All"])
    如:
    Update(OrderHistory, {Products:OldValue!Text}, {Products:NewValue!Text}, All)
  79. 更新上下文
    UpdateContext({Name1: Expression1, Name2: Expression2, …})
    如:
    UpdateContext({page: 5, displayItem: "Tablets"})
  80. 满足条件时更新集合
    UpdateIf(Collection, Condition1, {Column1: Expression1, …}[, Condition2, {Column1: Expression2, …} …])
    如:
    UpdateIf(ShoppingCart, Price > 200, {NumItems: 0})
  81. 转大写
    Upper(Text)
    Upper(ColumnExpression)
  82. 字符串转数字
    Value(Text)
  83. 获取方差
    VarP(Table, Expression)
    VarP(Expression1[, Expression2, ...])
    如:
    VarP(Sales, CostPerUnit * UnitsSold)
  84. 获取年
    Year(DateTime)

Project Siena - 函数

标签:

原文地址:http://www.cnblogs.com/rammderek/p/4249929.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!