SPONSORS:






User Tag List

Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Jul 2001
    Location
    NY, USA
    Posts
    67
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    String function differences

    hi,

    I am working on a login function. I tried using the following string function (I am reading data from a external txt file) and I get different results just because the password is alpha numeric in the second case.

    Any suggestions to overcome this problem?


    Thanks in advance!!! t file is also attached

    [-] testcase testpos() appstate none
    [ ]
    [ ] String userid1, passwd1
    [ ] String userid2, passwd2
    [ ]
    [ ] //password only numeric
    [ ] const String sLine1= 'user106367,123456'
    [ ]
    [ ] userid1 = trim(Left(sLine1,StrPos(",",sLine1)-1))
    [ ] passwd1 = trim(Right(sLine1,StrPos(",",sLine1)-1))
    [ ]
    [ ] Print(" when password is only numeric...")
    [ ] Print("userid1",userid1)
    [ ] print("passwd1",passwd1)
    [ ]
    [ ]
    [ ]
    [ ] //password is alpha numeric
    [ ] const String sLine2= 'user106367,user123456'
    [ ]
    [ ] userid2 = trim(Left(sLine2,StrPos(",",sLine2)-1))
    [ ] passwd2 = trim(Right(sLine2,StrPos(",",sLine2)-1))
    [ ]
    [ ] Print(" when password is alphanumeric...")
    [ ] Print("userid2",userid2)
    [ ] print("passwd2",passwd2)
    [ ]


    //results
    [-] // Testcase testpos - Passed
    [ ] // when password is only numeric...
    [ ] // userid1 user106367
    [ ] // passwd1 367,123456
    [ ]
    [ ] // when password is alphanumeric...
    [ ] // userid2 user106367
    [ ] // passwd2 user123456
    [ ]


    ------------------

  2. #2
    Senior Member
    Join Date
    Oct 1999
    Location
    Tyngsborough, MA
    Posts
    211
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: String function differences

    try this... changed the line with Right()

    ------------------

  3. #3
    Senior Member
    Join Date
    Jul 2001
    Location
    Elizabeth, CO, USA
    Posts
    653
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: String function differences

    Has nothing to do with the alphanumeric qualities. Has everything to do with the fact that, in the second case, the password is the same length as the userID.

    You see, StrPos returns the position from the left side of the string, so the first call to Right is taking more characters than it should (essentially, taking the length of the userid). You should have added the optional TRUE as the last argument to StrPos to get number of characters from the right end.

    Save yourself some hassles and use GetField as in...

    Or you could use SubStr...

    - Dave


    ------------------
    Amelior Technology
    dreed@ameliortech.com

    [This message has been edited by dcreed (edited 08-22-2001).]
    WaltzingRhino.com
    A concerned Borland customer, a fly in the ointment, a wrench in the works.

  4. #4
    Member
    Join Date
    Jul 2001
    Location
    NY, USA
    Posts
    67
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: String function differences

    thank you Brian and Dave for the inputs!! I got the fundamentals of Strpos clear now.

    Srikanth

    ------------------

  5. #5
    Member
    Join Date
    Mar 2000
    Posts
    75
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: String function differences

    In the above case you are better off using the GetField function. You know that there are always two fields (comma delimeter) and the user is 1 and pw is 2.

    Peter


    ------------------

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:14 AM.

Copyright BetaSoft Inc.