Home AMX User Forum NetLinx Studio

Finding a CR in a String

Greetings,

I have a string in which I need to replace $0D with $0A.

I am trying to locate the $0D with:
nWHERE=FIND_STRING(cVBL_TEXT_TO_SEND,$0D,3)

All I get is a 0 for nWHERE.

Any better suggestions for finding and replacing the CR?

Thanks.

Comments

  • Same old single character string thing

    Put quotes around any single character string to make it work properly:

    nWHERE=FIND_STRING(cVBL_TEXT_TO_SEND,"$0D",3)
  • viningvining Posts: 4,368
    In case you don't have the function, this is one that Dave got from the functions.axi file that kickin about.

    The function!
    DEFINE_FUNCTION CHAR[2000] fnReplace(CHAR strSTR[], CHAR strSEARCH[], CHAR strREPLACE[])
         {
         STACK_VAR INTEGER nPOS
         STACK_VAR CHAR strTRASH[2000]
         STACK_VAR CHAR strTEMP_STR[2000]
         nPOS = FIND_STRING(strSTR, "strSEARCH", 1)
         IF (!nPOS)
    	  RETURN strSTR;
         WHILE (nPOS)
    	  {
    	  strTEMP_STR = ""
    	  IF (nPOS > 1)
    	       strTEMP_STR = LEFT_STRING(strSTR, nPOS - 1)
    	  strTRASH = REMOVE_STRING(strSTR, "strTEMP_STR, strSEARCH", 1)
    	  strSTR = "strTEMP_STR, strREPLACE, strSTR"
    	  nPOS = FIND_STRING(strSTR, "strSEARCH", nPOS + LENGTH_STRING(strREPLACE))
    	  }
         RETURN strSTR;
         }
    

    Line to invoke the function.
     cYourThing = fnReplace(get_buffer_string(StringThing,nFBS - 1), "13", "10")
    
  • functions.axi

    >>In case you don't have the function, this is one that Dave got from the functions.axi file that kickin about.<<


    Sounds like that could be a very useful file to have. Where could I get it? Or could someone email that file to me? I NEVER like to re-invent wheels...


    Thanks,
    Bill Querry
    bquerry@crescentdigital.com
    Crescent Digital, LLC
  • Joe HebertJoe Hebert Posts: 2,159
    Tech Notes 659-662

    Check out the following Tech Notes for some useful string functions:

    TN659 - TRIM_STRING
    TN660 - FIND_STRING_REV
    TN661 - REPLACE_STRING
    TN662 - SPLIT_STRING
  • viningvining Posts: 4,368
    Well it wasn't really functions.axi this function was in strings.axi but in the zip there's dates.axi and math.axi.
  • DHawthorneDHawthorne Posts: 4,584
    Just so the right people get credited, the original strings.axi and math.axi files come from Leon ten Brundel, and can be found in this thread: http://www.amxforums.com/showthread.php?t=77 . I don't believe I have touched the math.axi file, but I have made quite a lot of changes to strings.axi ... mainly adding functions to it as I have found useful (and, I must confess, changning the names of some of Leon's originals just out of sheer fussiness for naming conventions I have personally adopted). The dates.axi file is all mine (and so would be any blame for bugs in it I have missed :)).

    This particular function is all Leon :).
Sign In or Register to comment.