VBScript to combine rs values, loop and add to duplicate(s) -


i've written lot of if statements in vbscript, haven't gone beyond apologize lack of experience. hope i'm asking simple do.

i want output item identifiers created 3 combined recordset field values , add "b" "c" "d" etc., duplicates. duplicates rare, happen occasionally. want meaningful item identification autonumbers not provide.

the following example works combine fields, need include script loop , find duplicates , add appropriate alpha character.

fyi: = alpha character, b = alpha character, c = reformatted date

 <% dim idcode  = (rs_table.fields.item("codea").value)   b = (rs_table.fields.item("codeb").value)  c = (fixeddate(rs_table.fields.item("date").value))  idcode = (a) & (b) & (c)  response.write idcode  %> 

example output: lc032414 example dupe output: lc032414b

thanks, i'm afraid ask , may find more pain it's worth!

i use dictionary store id's, since can add each key (which must unique) , test dictionary existence. this:

' on... create dictionary... set d = createobject("scripting.dictionary")  ' loop through records... until rs_table.eof      ' determine id...     idcode = rs_table("codea") & rs_table("codeb") & fixeddate(rs_table("date"))      ' check existence in dictionary...     if d.exists(idcode)          ' id exists. keep testing suffixes until find availability...         strletter = "b"          while d.exists(idcode & strletter)             strletter = chr(asc(strletter) + 1)         loop          d.add idcode & strletter, ""    ' add id/key. value unimportant.      else          ' id doesn't exist yet. add it.         d.add idcode, ""    ' add id/key. value unimportant.      end if      rs_table.movenext  loop 

when comes time print id's, can iterate dictionary's keys collection:

for each k in d.keys     response.write k next 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -