0

我试图在数据库中找到相同的登录 id 用户。

首先,我将每个用户都放到跳过列表中,然后我想逐个比较。我的问题是如何获得 Skiplist 上的关键值。

我的一段代码在这里:

for lUser in userList do {

    string uName = lUser.name
    string uEmail = lUser.email
    string uSys = lUser.systemLoginName
    string uAdr = lUser.address
    outBuf +=  uName sep uSys sep uEmail sep uAdr
    outBuf += "\n"

    // Here I have to add some code, I can put the values but not get again or compare
    // I need some for loop and get every key value
    put(skiplist,count,uSys)
    print count
    print "\n"
    count++
}

有人可以为此提供提示,我是这种语言的新手。提前致谢。

编辑:现在它正在工作

    pragma runLim,0
string sep = ";"
string dbName = getDatabaseName
print "\n" "List of doors user in database " getDatabaseName  ": \n\n"
int count = 0
User lUser

Group lGroup
Skip skiplist = create

for lUser in userList do {
  string uName = lUser.name
  string uEmail = lUser.email
  string uSys = lUser.systemLoginName
  string uAdr = lUser.address


  if(null uSys)
  {
    print uName " doesn't have a System Name.\n"
  } else {
    bool flagDuplicate = false
    string nameDuplicate = ""
    string s = ""
    for s in skiplist do {
      if(s == uSys) {
        flagDuplicate = true
        nameDuplicate = (string key skiplist)
        break
      }
    }

    if(flagDuplicate) print "Users '" uName "' and '" nameDuplicate "' have the same System Name (" uSys ").\n"
    else put(skiplist,uName,uSys)

  }
}

pragma runLim,0这一行是为了避免执行时间警告。

4

1 回答 1

1

听起来您正在寻找的是这样的:

for lUser in userList do {
  string uName = lUser.name
  string uEmail = lUser.email
  string uSys = lUser.systemLoginName
  string uAdr = lUser.address
  outBuf +=  uName sep uSys sep uEmail sep uAdr
  outBuf += "\n"

  if(null uSys)
  {
    print uName " doesn't have a System Name.\n"
  } else {
    bool flagDuplicate = false
    string nameDuplicate = ""
    string s = ""
    for s in skiplist do {
      if(s == uSys) {
        flagDuplicate = true
        nameDuplicate = (string key skiplist)
        break
      }
    }

    if(flagDuplicate) print "Users '" uName "' and '" nameDuplicate "' have the same System Name (" uSys ")."
    else put(skiplist,uName,uSys)

    print "\n"
  }
}

编辑:我添加了一个空白检查uSys,您可以在那里做任何您想做的事情,如果您只想将所有空的添加到列表中,然后在最后打印出来也可以。

这至少应该为您指明正确的方向。

注意:我目前无法测试此代码,因此如果有任何错误或拼写错误,我深表歉意。但我认为它会让你足够接近。

祝你好运!

于 2013-11-21T13:58:54.123 回答