Struct类

Struct可以拥有很多类型各不相同的字段和其值,也就相当于一行记录。

 

 

static void StructJob(Args _args)
{
    Struct      m_Struct = new Struct(Types::Integer,"ID",Types::String,"Name");
    int         i;
    
    ;
    m_Struct.value("ID",2);
    m_Struct.value("Name","Luck");
    m_Struct.add("Price",90);
    m_Struct.add("Level","VIP");
    
    info(m_Struct.toString());
    for(i = 1;i<=m_Struct.fields();i++)
    {
        info(strfmt("fieldN:%1,fieldT:%2,fieldV:%3",m_Struct.fieldName(i),m_Struct.fieldType(i),m_Struct.valueIndex(i)));
    }
}

 

posted @ 2011-10-09 16:24 Kurodo 阅读(27) 评论(0) 编辑

List类和Array类

List,可以添加相同的值,还可以选择是前面还是后面添加。List中元素的顺序是添加时的顺序,本身不会自动排序。

Array索引值是从1开始,长度可以动态添加,重复赋值时,新值将替换旧值。

 

static void ArrListJob(Args _args)
{
    List            m_List = new List(Types::String);
    ListEnumerator  m_ListEtor;
    Array           m_Arr = new Array(Types::String);
    int             m_ArrC;
    ;
    
    m_List.addEnd("Andy");
    m_List.addStart("Judy");
    m_List.addStart("Luck");
    m_List.addEnd("ANDY");
    
    info(m_List.toString());
    info(strfmt("count:%1",m_List.elements()));  //4
    m_ListEtor = m_List.getEnumerator();
    while(m_ListEtor.moveNext())
    {
        info(m_ListEtor.current());
    }
    
    info("===========");
    
    m_Arr.value(1,"A");
    m_Arr.value(1,"B");
    m_Arr.value(5,"C");
    m_Arr.value(3,"D");
    
    for(m_ArrC = 1; m_ArrC <= m_Arr.lastIndex();m_ArrC += 1)
    {
        info(strfmt("Key:%1 Value:%2",m_ArrC,m_Arr.value(m_ArrC)));
    }
}

 

posted @ 2011-10-09 15:58 Kurodo 阅读(49) 评论(0) 编辑

Set类

Set可以容纳相同类型的任意数据的值,其特点就是所有保存于Set的值都是排序并且唯一的,当插入重复的值时,

Set会自动忽略。比如字符串类型,不区分大小写。

Set还可以用作集合的并集(Union)、交集(Intersection)和差集(Defference)运算。

Union:A集合元素与B集合元素,合并。

Intersection:A集合与B集合都存在的元素,交集。

Defference:A集合与B集合不相同的元素,以后者为主,取前者。

 

static void SetJob(Args _args)
{
    Set             m_SetStr = new Set(Types::String);
    Set             m_SetA = new Set(Types::Integer);
    Set             m_SetB = new Set(Types::Integer);
    SetEnumerator   m_SetEtor;
    ;
    
    m_SetStr.add("Andy");
    m_SetStr.add("Judy");
    m_SetStr.add("Luck");
    m_SetStr.add("ANDY");
    
    info(strfmt("%1",m_SetStr.in("Andy"))); //true
    info(m_SetStr.toString());
    info(strfmt("count:%1",m_SetStr.elements()));//3
    m_SetEtor = m_SetStr.getEnumerator();
    while(m_SetEtor.moveNext())
    {
        info(m_SetEtor.current());
    }
    m_SetStr.remove("Luck");
    
    info("============");
    
    m_SetA.add(1);
    m_SetA.add(2);
    m_SetA.add(3);
    
    m_SetB.add(3);
    m_SetB.add(4);
    m_SetB.add(5);
    
    info(set::union(m_SetA,m_SetB).toString()); //1,2,3,4,5
    info(set::intersection(m_SetA,m_SetB).toString()); //3
    info(set::difference(m_SetA,m_SetB).toString()); //1,2
}

 

 

posted @ 2011-10-09 15:23 Kurodo 阅读(78) 评论(0) 编辑

Map类

Map同时保存一个索引键(Keys)和一个值(Values),键和值都可以是指定的数据类型。

键不能重复,但值可以重复。所以,多个键可以指向同一个值,但是一个键只能有一个值。

当插入的键已经存在时,Map会使用新的值替换旧的值。Map会根据Key进行自动排序。

这里使用MapEnumerator枚举输出。

 

 

static void MapJob(Args _args)
{
    Map             m_Map = new Map(Types::Integer,Types::String);
    MapEnumerator   m_MapEtor;
    ;
    
    m_Map.insert(1,"A");
    m_Map.insert(1,"B");
    m_Map.insert(4,"C");
    m_Map.insert(2,"C");
    
    info(strfmt("总元素个数:%1",m_Map.elements()));  //3
    
    if(m_Map.exists(2))
        info(strfmt("值:%1",m_Map.lookup(2))); //C
        
    info(m_Map.toString());
    m_MapEtor = m_Map.getEnumerator();
    while(m_MapEtor.moveNext())
    {
        info(strfmt("Key:%1,Value:%2",m_MapEtor.currentKey(),m_MapEtor.currentValue()));
    }
        
}

 

 

posted @ 2011-10-09 14:59 Kurodo 阅读(42) 评论(0) 编辑

Stack类和StackBase类

Stack是一种后进先出的数据结构类型(Last In First Out),只能容纳一种类型,即容器类型(container)。

所以它的push方法的参数是container类型的,我们可以["Something"]这样写。

 

StackBase是Stack的子类,加强型。这个命名够蛋疼的,不知道的还以为是Stack的父类。StackBase除了

拥有Stack类似的特性外,它还可以容纳任意指定的类型,并增加了索引方法peek。

 

代码如下

 

static void StackJob(Args _args)
{
    Stack       m_stack = new Stack();
    StackBase   m_stackBase = new StackBase(Types::String);
    ;
    m_stack.push(["Item001"]);
    m_stack.push(["Item002"]);
    info(strfmt("%1",m_stack.qty())); // 2
    info(strfmt("%1",conpeek(m_stack.pop(),1))); //Item002
    info(strfmt("%1",conpeek(m_stack.pop(),1))); //Item001
    
    info("=============");
    
    m_stackBase.push("A");
    m_stackBase.push("B");
    info(strfmt("%1",m_stackBase.count()));  // 2
    info(strfmt("%1",m_stackBase.peek(2)));  // B
    info(strfmt("%1",m_stackBase.pop()));  //B
    info(strfmt("%1",m_stackBase.pop()));  //A
}

 

posted @ 2011-10-09 14:40 Kurodo 阅读(39) 评论(0) 编辑

信息提示图标

会用到的图标如图,代码如下

 

static void MsgJob(Args _args)
{
    int i,j;
    ;
    Info("Msg!");
    Warning("Warning!");
    Error("Error!");
    setprefix("Group One:");
    for(i = 1; i<3;i++)
    {
        setprefix(strfmt("No.%1",i));
        for(j = 1;j<4;j++)
            info(strfmt("Sub.%1",j));
    }
}

 

posted @ 2011-10-09 14:09 Kurodo 阅读(31) 评论(0) 编辑

数据多选行

多选数据行的操作,用户很常用到。这里说一下,Button的属性中,MultiSelect属性改为Yes,Name属性改为SelectMultiRecord,即开启了按钮多选行。

然后代码

void clicked()
{
    MultiSelectionHelper  m_Helper;
    CustTable             m_Table;
    ;
    super();

    m_Helper = MultiSelectionHelper::createFromCaller(element);
    for(m_Table = m_Helper.getFirst();m_Table;m_Table = m_Helper.getNext())
    {
        info(strfmt("帐号:%1,名称:%2",m_Table.AccountNum,m_Table.Name));
    }
}

 

 

posted @ 2011-10-09 13:19 Kurodo 阅读(62) 评论(0) 编辑