Draw a string with one character in a different color

This problem sounds trivially simple, but I don't have a clue on how to implement it.
What I'm basically trying to do, is use Graphics2D.drawString() to draw a string...but I want one letter to be in a different color. Guessing from the API this could be possible with an AttributedCharacterIterator, but I don't know how to set 'color' as one of the attributes.
Does anyone with knowledge of Java 2D havy any solution for this?

keeskist wrote:
This problem sounds trivially simple, but I don't have a clue on how to implement it.
What I'm basically trying to do, is use Graphics2D.drawString() to draw a string...but I want one letter to be in a different color. Guessing from the API this could be possible with an AttributedCharacterIterator, but I don't know how to set 'color' as one of the attributes.
Does anyone with knowledge of Java 2D havy any solution for this?Here's an example using AttributedString/AttributedCharacterIterator:
import java.awt.*;
import java.awt.font.TextAttribute;
import java.text.AttributedString;
import javax.swing.*;
public class AttributedCharacterIteratorDemo extends JFrame {
     public AttributedCharacterIteratorDemo() {
          AttributedString as = new AttributedString("Hello, world!");
          as.addAttribute(TextAttribute.FOREGROUND, Color.RED, 2, 3);
          JPanel cp = new ACRPanel(as);
          cp.setPreferredSize(new Dimension(300,300));
          setContentPane(cp);
          setTitle("AttributedCharacterIterator Demo");
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          pack();
     public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
               public void run() {
                    new AttributedCharacterIteratorDemo().setVisible(true);
     private class ACRPanel extends JPanel {
          private AttributedString as;
          public ACRPanel(AttributedString as) {
               this.as = as;
          protected void paintComponent(Graphics g) {
               g.drawString(as.getIterator(), 40,40);
}

Similar Messages

  • Replacing all occurrences of characters in a string with one new character?

    Hi there,
    I'm looking for a way that I could replace all occurrences of a set of specific characters with just one new character for each occurrence.
    For example if I have a string which is "word1...word2.......word3....word4............word5" how would I be able to replace this with just one character such as ":" for each set of "." so that it would essentially appear like this "word1:word2:word3:word4:word5"
    If I just use replace(".", ":") I am left with "word1:::word2:::::::word4::::word5::::::::::::"
    So therefore I'm guessing this would require the use of replaceAll() maybe? but I'm not really very familiar with how regular expressions work and how this would be accomplished using them.
    Any help would be greatly appreciated :) Thanks.

    Yes, but "." means any character, so ".\+" means "any character repeated more than once". If you just mean a full stop ("period" for you Americans :p) you should use "\.+" as your regular expression, but remember that for Java you need a '\' escape to recognise '\' as '\', so in code you'd actually type your regex as:
    "\\.+"Here's an example of one way to do it:
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    public class Test {
        public static void main(String[] args) {
           String string = "example1.......example2...example3.....example4";
         Pattern pattern = Pattern.compile("\\.+");
         Matcher stringMatcher = pattern.matcher(string);
         string = stringMatcher.replaceAll(":");
         System.out.println(string);
    }Edited by: JohnGraham on Oct 24, 2008 5:19 AM
    Edited by: JohnGraham on Oct 24, 2008 5:22 AM

  • Find files that match with given string, except one character in a fixed position

    Hi,
    I want to find files in a directory with a given string (ss-20140129-process-000*.sdx), where only one character will be mismatched, so have to use wildcard for that character. This means I am looking for filenames where everything needs to be matched except
    one character in position of "*". For the samples given below: 1st 3 files matched with the given string, but last 3 files have not matched, so first 3 files will be counted.
    ss-20140129-process-0001.sdx
    ss-20140129-process-0004.sdx
    ss-20140129-process-0009.sdx
    zx-20140129-process-0001.sdx
    bt-20140129-process-0002.sdx
    zx-20140129-process-0001.sdx
    I can use the command like (GCI -path $folder -filter ss-20140129-process-000?.sdx), BUT problem is i am building a string for the filter (code given below), where i DO NOT know how to use "?" within the string to make a character exception.
    Code:
    $datevalue = [datetime]::parseexact($trandate,"MMddyy",$null)
    $yyyymmdd = $datevalue.tostring('yyyyMMdd')
    $FileToCheck = ("ss-"+$yyyymmdd+"-process-000?.sdx")
    GCI -path $folder -filter $FileToCheck
    But it's definitely NOT working for syntax problem.
    Any help?

    I don't think it's a syntax issue in the filter.  This works fine for me:
    $yyyymmdd = '20140129'
    $FileToCheck = ("ss-"+$yyyymmdd+"-process-000?.sdx")
    Get-ChildItem -Path . -Filter $FileToCheck
    <#
    Output:
    Directory: C:\source\Temp\sdxtext
    Mode LastWriteTime Length Name
    -a--- 1/30/2014 10:16 AM 0 ss-20140129-process-0001.sdx
    -a--- 1/30/2014 10:16 AM 0 ss-20140129-process-0004.sdx
    -a--- 1/30/2014 10:16 AM 0 ss-20140129-process-0009.sdx
    #>
    You can try adding some debug output right before the call to Get-ChildItem. Check the values of $Folder and $FileToCheck, make sure they're correct. You can also fiddle with the values and call Get-ChildItem manually until it works, which would then tell you
    how the code needs to be changed.

  • How to split a string with linefeed character ( LF ) as a delimiter in VB6?

    Hi. I am writing a small program in VB 6.0. 
    I have a string named Data and it contains few characters along with <LF> in it. ( <LF> is a new line/line feed character).
    I want to split this string with <LF> as delimiter and store the tokens in an array. I tried with split function and its giving me type mismatch error. Can anyone tell me how to do it?
    I am giving the pseudo-code below.
    Dim Data as string
    Data = "hello, how are you<LS>good morning guys <LS> hi"
    Dim strarray() as stringMsgbox(Data)
    strarray = split(Data, "<LS>")
    When i see the Data in message box before split function, it shows up in different lines like this:
    hello, how are you
    good morning   guys 
    hi
    I want the final array strarray to be like this:   strarray(0) = "hello, how are you"
    strarray(1) = "good morning   guys "
    strarray(2)  = " hi"
    The spaces can be as it is. Just i need the string to be delimited wherever <LS> is there.
    Please help me as soon as possible. Though it is small one, i am stuck here.
    Thanks in advance,
    Satya.

    Hello,
    This forum is for VB.NET, please check the following resources
    http://www.vbforums.com/forumdisplay.php?1-Visual-Basic-6-and-Earlier
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/6a0719fe-14af-47f7-9f51-a8ea2b9c8d6b/where-to-post-your-vb-6-questions?forum=vbgeneral
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • Multiple IOS devices with one apple id and different PCs to synch

    I have 2 macs, 1 Apple TV, 2 iPhones, 2 iPads, 3 iPods and 1 windows pc.
    I would like to:
    1) sync each of them with one of the Macs using the same apple Id;
    2) connect with FaceTime with each of them separately (at least the iPads and iPhones);
    3) synch one phone with the Mac for music and my work PC for apps.
    What should I do using my unique apple I'd?
    Txs,
    Roberto

    When you say "sync", are you talking about physically having songs, movies, etc on your computers and devices?  Or simply want to access those files on those computers and devices?  *Syncing is different from Home Sharing but you are in the Home Sharing discussion forum.  That is why I am asking.
    If they are all in the same network and just want to access them or listen/watch them, all you have to do is turn on Home Sharing for all of your machines and devices with the same account.
    For Mac/PC desktops, you can turn on Home Sharing in iTunes 11.  Go to File > Home Sharing > Turn on Home Sharing.  Do this for all machines.  After doing that, you go to the media selector button at the top left to see your Home Shares.  Or you can enable the sidebar by going to View > Show Sidebar.  From there, just connect to your other computers and you will able to listen or watch to your content.
    For your devices, turn on Home Sharing in Settings.  Go to Settings > Music or Video > Home Sharing and enter the same Apple ID and password.  You can listen to songs in Music and watch videos in Video.app.
    For your Apple TV, if it is a 2nd gen ATV or later then you can turn on Home Sharing under Computers in the main screen.  For the 1st gen ATV, you can either share or pair with iTunes.
    If you want to physically have files (this is syncing), then you can sync your devices to the machine you want to sync with.
    With respect to FaceTime, if you want to use FaceTime on your phone with someone but separately on your iPad then you can associate your phone number to FT on your phone and on your iPad, you can use your Apple ID for FaceTime.  That way, if people want to FT on your phone, they should use the phone number to FT.  For iPad, people should enter your Apple ID when doing FT.

  • HP Officejet pro 8500a prints endless stream of un-ordered blank sheets with one character on them

    My HP Officejet Pro 8500a worked fine until about 2 weeks ago (it is about 3 months old).  It began printing endlessly (during a period that no documents are being sent to the printer - I want to be clear this is not in regard to ORDERED documents from any of the computers).  It prints out a sheet of paper with a D in the first character spot in the left top corner, then spits out the paper.  It keeps going until it runs out of paper.  The only way to stop it is to 1) turn it off  2)keep pressing the "cancel print" button (every 5-10 seconds) or 3) take out the paper.  This of course is a hassle because while actually trying to print a document (which does come out fine), we have to load fresh paper and lose several pieces while the printer continues it's freak out before printing our ORDERED document.  
    Spent almost 2 1/2 hours on tech support yesterday - it took 2 hours to MAKE IT CLEAR that the printer was PRINTING ON IT'S OWN.  The tech kept trying to "fix" the documents I was printing (which are FINE, as I said).  Finally, I was told that a higher level tech would have to call me back - but looking through forums, it appears that's an empty promise and no point in waiting for assitance.
    Any suggestions?
    This question was solved.
    View Solution.

    Let's start by resetting the printer.  Turn it off, hold the # and 6 keys while and a bit after turning it back on.
    What router brand/model are you using?  What operating system on your computer?
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • PB printing with Adobe PDF, missing text, different colors

    Hello,
    I use Adobe Reader 9, I tried with the latest updates: the same
    On some pdf docs I print missing parts of the entire text.
    And I have also some areas of color deviations between what I have on the screen and on paper. I tested different printers and PC: the same.
    It works with Foxit reader. What makes that it does not work with Adobe Reader? Have you ever encountered such a pb?
    (I can not keep Foxit Reader on my business PC)
    thank you for your answers
    Nico

    Could you please test this with Reader X. See if that works.
    Here's the link to download Reader X : http://get.adobe.com/reader/?promoid=BUIGO
    Regards,

  • One character wrong color?

    I have received an In Design Document
    I am on a Mac
    I sent the file to print and strangely one character of a font is printing a different color.
    I have checked opacity, tints,
    I have converted the file to CMYK PDF
    I have converted the pantone color to CMYK, tried RGB,
    and each time I try to print the file only that one character is a different color than the others in the file.
    Please help I am on DEADLINE
    Happy thanksgiving

    Does this "1" character show up all over the doc or is it in just one place?
    Have you looked to see it the designer has inadvertently applied color to this one char?
    Let us know

  • How to style type with varying character baseline heights

    I need to find a fast way of styling type with varying character baseline heights? I want to give the impression of jiggly type with each character having a different baseline shift. Any suggestions on a script that might help me?
    each character of the sentence will have a different baseline shift value.
    the baseline shifts are a repeating sequence of the following values:
    2, -1, 1, 2,3,-1, 0,-2,-1,0
    Is there a script I could use or modify to help me with this?
    At present I have to modify each individual character which is very time consuming
    Thanks

    Dave, thanks for your response, i think the tpye needing styling would be selected first.
    The type needed to be styled is a single paragraph at the most.
    So you think a bunch of individual character styles grouped into a nested style as part of a paragraph style could work?
    I shall investigate nested styles
    Thanks for your help and suggestions much appreciated
    Andy

  • How to prevent the String Tokenizer filter more than one character

    I am wrinting a simple program to cut the long string into small piece of data with the delimiters "#####" by using StringTokenizer
    For example:
    String output ="Apple Company #####APPLECOMPANY48877 #####2005-01-01 #####TESTING1 ##### ##### ##### ##### #####MR.Apple Wong #####[email protected] #####0-852-34183741 #####0-852- #####XYZ #####Apple in the tree road #####ROOM 3T099, LEVEL 9, All WIN BLDC ##### ##### #####NT #####34KJFG45 |||||0.0000 |||||1 |||||3 |||||3";
    StringTokenizer st = new StringTokenizer(output,"#####");
    int i=0;
    while(st.hasMoreTokens()){
    System.out.println("The number is: " i" "+st.nextToken());
    i++;
    The result is
    The number is: 0 Apple Company
    The number is: 1 APPLECOMPANY48877
    The number is: 2 2005-01-01
    The number is: 3 TESTING1
    The number is: 4
    The number is: 5
    The number is: 6
    The number is: 7
    The number is: 8 MR.Apple Wong
    The number is: 9 [email protected]
    The number is: 10 0-852-34183741
    The number is: 11 0-852-
    The number is: 12 XYZ
    The number is: 13 Apple in the tree road
    The number is: 14 ROOM 3T099, LEVEL 9, All WIN BLDC
    The number is: 15
    The number is: 16
    The number is: 17 NT
    The number is: 18 34KJFG45 |||||0.0000 |||||1 |||||3 |||||3----->
    It is correct!!!!!!
    But, if the one of the small string in the long string contain the character "#", I found the "#####" and "#" also trace as delimiters by StringTokenizers to filter the String such as following example:
    I only add one more "#" in String "ROOM 3T099, LEVEL 9," from the above example:
    String output ="Apple Company #####APPLECOMPANY48877 #####2005-01-01 #####TESTING1 ##### ##### ##### ##### #####MR.Apple Wong #####[email protected] #####0-852-34183741 #####0-852- #####XYZ #####Apple in the tree road #####ROOM #3T099, LEVEL 9, All WIN BLDC ##### ##### #####NT #####34KJFG45 |||||0.0000 |||||1 |||||3 |||||3";
    StringTokenizer st = new StringTokenizer(output,"#####");
    int i=0;
    while(st.hasMoreTokens()){
    System.out.println("The number is: " i" "+st.nextToken());
    i++;
    But the result is:
    The number is: 0 Apple Company
    The number is: 1 APPLECOMPANY48877
    The number is: 2 2005-01-01
    The number is: 3 TESTING1
    The number is: 4
    The number is: 5
    The number is: 6
    The number is: 7
    The number is: 8 MR.Apple Wong
    The number is: 9 [email protected]
    The number is: 10 0-852-34183741
    The number is: 11 0-852-
    The number is: 12 XYZ
    The number is: 13 Apple in the tree road
    The number is: 14 ROOM
    The number is: 15 3T099, LEVEL 9, All WIN BLDC
    The number is: 16
    The number is: 17
    The number is: 18 NT
    The number is: 19 34KJFG45 |||||0.0000 |||||1 |||||3 |||||3
    I have found that the StringTokenizer trace "#####" and "#" to be delimiters to filter the String, I only want to filter the String by StringTokenizer with "#####" not include "#"
    So What Can I Do? Is it
    StringTokenizer st = new StringTokenizer(output,"#####");
    not Correct?
    It is thank a lot if anyone can help me! thx!!

    If I must use StringTokenizer, How can I do it? You completely misunderstand how StringTokenizer works.
    StringTokenizer st = new StringTokenizer(output,"#####");Each character is used as a delimiter. So you have specified the same delimiter 5 times.
    As suggested above you would need to rewrite the entire code, to treat the String as a delimiter, intead of each character as a delimiter.

  • Reading a string one character at a time

    Hi,
    I'm hoping you use SmallBasic for year 10 exam students at my school.  But, I have found a problem I cannot solve.
    I need to be able to read one character at a time from a string (txt file) and convert each char to its ACSII code.
    How do to I read one char at a time from a string to enable processing?
    Thanks for your help.
    Baz 

    Here is an over the top solution that will display the Hex value of the character codes of every character in the file.
    TextWindow.Write("Enter full file name: ")
    filnam = TextWindow.Read()
    contents = File.ReadContents(filnam) 'read the entire file
    TextWindow.Clear()
    TextWindow.WriteLine("File Name: " + filnam)
    TextWindow.WriteLine("Offset: 0")
    col = 0
    row = 5
    TextWindow.CursorLeft = col
    TextWindow.CursorTop = row
    For i= 1 To Text.GetLength(contents)
    ch = Text.GetSubText(contents, i,1)
    chVal = Text.GetCharacterCode(ch)
    ConvertToHex()
    TextWindow.CursorLeft = col
    If chVal < 32 Then
    TextWindow.Write(".")
    Else
    TextWindow.Write(ch)
    EndIf
    TextWindow.CursorLeft = 20 + 2 + (col * 3)
    TextWindow.Write(Text.GetSubText(hexstr,1,2))
    col = col + 1
    If col = 8 Then
    col = col + 1
    EndIf
    If col > 16 Then
    col = 0
    row = row + 1
    If row > 20 then
    TextWindow.CursorTop = 23
    TextWindow.CursorLeft = 25
    TextWindow.Write("< < < Press ENTER to Continue > > >")
    TextWindow.Read()
    TextWindow.Clear()
    TextWindow.WriteLine("File Name: " + filnam)
    TextWindow.WriteLine("Offset: " + i)
    row = 5
    EndIf
    TextWindow.CursorTop = row
    EndIf
    EndFor
    TextWindow.WriteLine("")
    TextWindow.WriteLine("")
    Sub ConvertToHex
    HexValue[0] = "0"
    HexValue[1] = "1"
    HexValue[2] = "2"
    HexValue[3] = "3"
    HexValue[4] = "4"
    HexValue[5] = "5"
    HexValue[6] = "6"
    HexValue[7] = "7"
    HexValue[8] = "8"
    HexValue[9] = "9"
    HexValue[11] = "A"
    HexValue[12] = "B"
    HexValue[13] = "C"
    HexValue[14] = "D"
    HexValue[15] = "E"
    val = chVal
    hexstr = "h" 'Need to force Small basic to concatenate rather than add
    While val > 0
    hexPos = Math.Remainder(val, 16)
    hexstr = HexValue[hexPos] + hexstr
    val = Math.Floor(val / 16)
    EndWhile
    For hi = Text.GetLength(hexstr) To 2
    hexstr = "0" + hexstr
    EndFor
    EndSub
    Enjoy!

  • Changing one character in a string...how hard can it be...???

    Hey guys,
    I posted something the other day about changing a binary string to one complement. Well, now I want to change that again to the two's complement of the same number.
    The (messy) code I got so far is as follows:
    import java.util.*;
    class twosComplement {
      public static void main(String[] args) {
          Scanner reader = new Scanner(System.in);
          String binary;
          String i = "0";
          String j = "1";
          System.out.println("Enter a binary String:");
          binary = reader.nextLine();
       //   int x = 15;
       // String binary = Integer.toBinaryString(x);
       // binary = ("00000000"+binary).substring(8-binary.length());
        System.out.println("Your binary number is " +binary);
        String complement = binary.replaceAll("0","x").replaceAll("1","0").replaceAll("x","1");
        System.out.println("One's complement of your binary number is " +complement);
        int n = 0;
        int k = binary.length()-n;
        String m = charAt(k);
        if (charAt(k).equals(i)) binary.replace(charAt(k), j);
        else n++;
        System.out.println(binary);
    //    do {k++; }
    //    while (charAt(k).equals(i)) 
        private static String charAt(int k) {
            throw new UnsupportedOperationException("Not yet implemented");
        }the bit at the bottom is something netbeans kindly offered to create for me, it cut out a few syntax errors but didn't quite get the program to work.
    I'm pretty sure the root of my troubles is coming from the use of the "charAt" method, which as far as i know, would be better used with arrays, but I don't know of another way to sort this stuff...
    any help would be muchly appreciated.
    Aaron.

    ok. The following is a section from the original code (see above). I was hoping this code would take a binary string (ie, '1010101') and change the least significant bit which is a '0' to a '1'. The following section is my attempt at solving this problem, but as I run it, I encounter errors. I've been studying java for 2 months. I would like to know if anybody knows WHY this isn't working, and could offer an alternative method (as I've already stated, I think the use of the method 'charAt' is the main problem)
    int n = 0;
        int k = binary.length()-n;
        String m = charAt(k);
        if (charAt(k).equals(i)) binary.replace(charAt(k), j);
        else n++;
        }Is that better?

  • Getting one character at a certain position from a string array

    Hi, i'm new at learning java, but have strong experience at C++ and asm. How would i get one character at a certain positon from a string array.
    for example:
    String Phrases[] = {"To be or not to be, that is the question","The Simpsons","The Mole","Terminator three rise of the machines","The matrix"};
    that is my string array above.
    lets say i wanted to get the first character from the first element of the array which is "T", how would i get this

    ok well that didn't work, but i found getChars function can do what i want. One problem, how do i check the contents of char array defined as char Inchar[];

  • I would like to do a program that have one string control and one string indicator, any character that I type in the string control in the same time it will be appear in another string (indicator). How can help me?

    I would like to do a program that have one string control and one string indicator, any character that I type in the string control in the same time it will be appear in another string (indicator). How can help me?

    Why not use an event
    Add a While Loop, inside the loop add the Event Sructure.
    Now in the event structure selecd the String Controls.value change event to
    react
    and the new value inside the event that you get,( connect to the String
    indicator box.
    On Sun, 10 Aug 2003 15:58:47 -0500 (CDT), WiltonFilho wrote:
    > I would like to do a program that have one string control and one
    > string indicator, any character that I type in the string control in
    > the same time it will be appear in another string (indicator). How can
    > help me?
    >
    > I would like to do a program that have one string control and one
    > string indicator, any character that I type in the string control in
    > the same time it will be appear in another string (indicator). How can
    > help me?
    >
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

  • Stepping through a query result set, replacing one string with another.

    I want to write a function that replaces the occurance of a string with another different string.  I need it to be a CF fuction that is callable from another CF function.  I want to "hand" this function an SQL statement (a string) like this:   (Please note, don't bother commenting that "there are eaiser ways to write this SQL..., I've made this simple example to get to the point where I need help.  I have to use a "sub_optimal" SQL syntax just to demonstrate the situation)
    Here is the string I want to pass to the function:
    SELECT
      [VERYLONGTABLENAME].FIRST_NAME,
      [VERYLONGTABLENAME].LAST_NAME,
      [VERYLONGTABLENAME].ADDRESSS
    FROM
      LONGTABLENAME [VERYLONGTABLENAME]
    Here is the contents of the ABRV table:
    TBL_NM,  ABRV    <!--- Header row--->
    VERYLONGTABLENAME, VLTN
    SOMEWHATLONGTALBENAME, SLTN
    MYTABLENAME, MTN
    ATABLENAME, ATN
    The function will return the original string, but with the abreviations in place of the long table names, example:
    SELECT
      VLTN.FIRST_NAME,
      VLTN.LAST_NAME,
      VLTN.ADDRESSS
    FROM
      LONGTABLENAME VLTN
    Notice that only the table names surrounded by brackets and that match a value in the ABRV table have been replaced.  The LONGTABLENAME immediately following the FROM is left as is.
    Now, here is my dum amatuer attempt at writing said function:  Please look at the comment lines for where I need help.
          <cffunction name="AbrvTblNms" output="false" access="remote" returntype="string" >
            <cfargument name="txt" type="string" required="true" />
            <cfset var qAbrvs="">  <!--- variable to hold the query results --->
            <cfset var output_str="#txt#">  <!--- I'm creating a local variable so I can manipulate the data handed in by the TXT parameter.  Is this necessary or can I just use the txt parameter? --->
            <cfquery name="qAbrvs" datasource="cfBAA_odbc" result="rsltAbrvs">
                SELECT TBL_NM, ABRV FROM BAA_TBL_ABRV ORDER BY 1
            </cfquery>
         <!--- I'm assuming that at this point the query has run and there are records in the result set --->
        <cfloop index="idx_str" list="#qAbrvs#">      <!--- Is this correct?  I think not. --->
        <cfset output_str = Replace(output_str, "#idx_str#", )  <!--- Is this correct?  I think not. --->
        </cfloop>               <!--- What am I looping on?  What is the index? How do I do the string replacement? --->
            <!--- The chunck below is a parital listing from my Delphi Object Pascal function that does the same thing
                   I need to know how to write this part in CF9
          while not Eof do
            begin
              s := StringReplace(s, '[' +FieldByName('TBL_NM').AsString + ']', FieldByName('ABRV').AsString, [rfReplaceAll]);
              Next;
            end;
            --->
        <cfreturn output_txt>
        </cffunction>
    I'm mainly struggling with syntax here.  I know what I want to happen, I know how to make it happen in another programming language, just not CF9.  Thanks for any help you can provide.

    RedOctober57 wrote:...
    Thanks for any help you can provide.
    One:
    <cfset var output_str="#txt#">  <!--- I'm creating a local
    variable so I can manipulate the data handed in by the TXT parameter.
    Is this necessary or can I just use the txt parameter? --->
    No you do not need to create a local variable that is a copy of the arguments variable as the arguments scope is already local to the function, but you do not properly reference the arguments scope, so you leave yourself open to using a 'txt' variable in another scope.  Thus the better practice would be to reference "arguments.txt" where you need to.
    Two:
    I know what I want to happen, I know how to make it happen in another programming language, just not CF9.
    Then a better start would be to descirbe what you want to happen and give a simple example in the other programming language.  Most of us are muti-lingual and can parse out clear and clean code in just about any syntax.
    Three:
    <cfloop index="idx_str" list="#qAbrvs#">      <!--- Is this correct?  I think not. --->
    I think you want to be looping over your "qAbrvs" record set returned by your earlier query, maybe.
    <cfloop query="qAbrvs">
    Four:
    <cfset output_str = Replace(output_str, "#idx_str#", )  <!--- Is this correct?  I think not. --->
    Continuing on that assumption I would guess you want to replace each instance of the long string with the short string form that record set.
    <cfset output_str = Replace(output_str,qAbrs.TBLNM,qAbrs.ABRV,"ALL")>
    Five:
    </cfloop>               <!--- What am I looping on?  What is the index? How do I do the string replacement? --->
    If this is true, then you are looping over the record set of tablenames and abreviations that you want to replace in the string.

Maybe you are looking for