Question

I am trying to find the same login id users in database.

First I put every user to skiplist then I want to compare one by one. My question is how can i get the key value on Skiplist.

The piece of my code is here :

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++
}

Could someone give tips for this, I am new on this language. Thanks in advance.

EDIT: NOW IT IS WORKING

    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 this line is for avoiding the execution time warning.

Was it helpful?

Solution

It sounds like what you are looking for is this:

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"
  }
}

EDIT: I added a check for a blank uSys, you can do anything you want there, if you want to just add all the empty ones to a list then print it out at the end that would work too.

This should at least point you in the right direction.

NOTE: I don't have the ability to test this code currently so I apologize if there are any errors or typos. But I think it will get you close enough.

Good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top