How to add a character at the end of an array element that meets certain criteria.

Hi. I am using CF 9.2.1. I started learning CF yesterday, and I am trying to figure out a way to add a special character (like "?", "!"," & ") to an array row if the first row element (say, element [1][1]) has a specific letter like " t" in the word it is holding. In this case the special character will be added at the end of the last row element (element [1][3]).
Example: The take columns are: "Firstname", "Lastname", "Age".  If Firstname contains an "s" or "S" (in any order) then add "!" at the end of the row so that :
Sam, Rubins, 26 !
Nick, Palo, 32
Robert, Williams, 28
Oscar, Ramirez, 23 !
I tried using the ReReplace, Refind and the #findoneof functions. I could probably loop through the array and return a value and store, while storing the value in a separate variable and using an if/Boolean function to compare that value and so on.... But I am sure there's an easier and more efficient way. Thanks in advance.
<!--- #1 I will create a three column query named CityInfo--->
<cfset CityInfo = QueryNew("City, State, LCode","VarChar, VarChar, Integer")>
<cfset newRow = QueryAddRow(CityInfo, 2)>
<cfset newRow = QueryAddRow(CityInfo, 3)>
<cfset newRow = QueryAddRow(CityInfo, 4)>
<cfset newRow = QueryAddRow(CityInfo, 5)>
<cfset newRow = QueryAddRow(CityInfo, 6)>
<!---Using the column names City, Sate and LCode I will now enter the information--->
<cfset temp = QuerySetCell(CityInfo, "City", "Dallas", 1)>
<cfset temp = QuerySetCell(CityInfo, "State", "TX", 1)>
<cfset temp = QuerySetCell(CityInfo, "LCode", "214", 1)>
<cfset temp = QuerySetCell(CityInfo, "City", "Fort Worth", 2)>
<cfset temp = QuerySetCell(CityInfo, "State", "TX", 2)>
<cfset temp = QuerySetCell(CityInfo, "LCode", "817", 2)>
<cfset temp = QuerySetCell(CityInfo, "City", "San Antonio", 3)>
<cfset temp = QuerySetCell(CityInfo, "State", "TX", 3)>
<cfset temp = QuerySetCell(CityInfo, "LCode", "210", 3)>
<cfset temp = QuerySetCell(CityInfo, "City", "L.A.", 4)>
<cfset temp = QuerySetCell(CityInfo, "State", "CA", 4)>
<cfset temp = QuerySetCell(CityInfo, "LCode", "213", 4)>
<cfset temp = QuerySetCell(CityInfo, "City", "Austin", 5)>
<cfset temp = QuerySetCell(CityInfo, "State", "TX", 5)>
<cfset temp = QuerySetCell(CityInfo, "LCode", "512", 5)>
<h4> Number1. City info TABLE contents:</h4>
<cfoutput query = "CityInfo">
#City# #State# #LCode#<br>
</cfoutput> 
<!--- #2 Now I focus on the array. I declare it first --->
<cfset cityarray=arraynew(2)>
<!--- Then I retrieve the data and populate the array --->
<cfloop query="CityInfo">
<cfset cityarray[CurrentRow][1]=City>
<cfset cityarray[CurrentRow][2]=State>
<cfset cityarray[CurrentRow][3]=LCode>
</cfloop>
<h4>Number2. City info ARRAY contents before appending:</h4>
<cfloop index="Counter" from=1 to=5>
<cfoutput>
City: #cityarray[Counter][1]#,
Estate: #cityarray[Counter][2]#,
Code: #cityarray[Counter][3]#<br>
</cfoutput>
</cfloop>
<!--- #3 I now add/append Irving to the array and change L.A. --->
<cfset cityarray[6][1] = "Irving" />
<cfset cityarray[6][2] = "Texas" />
<cfset cityarray[6][3] = "972" />
<cfset cityarray[4][1] = "Los Angeles" />
<h4>Number3. City info Array contents after adding Irving, TX and updating L.A.:</h4>
<cfloop index="Counter" from=1 to=6>
<cfoutput>
City: #cityarray[Counter][1]#,
Estate: #cityarray[Counter][2]#,
Code: #cityarray[Counter][3]#<br>
</cfoutput>
</cfloop>
<br>
<!--- #4 now I look for the 's' in order to add a '!' THIS IS WHERE MY PROBLEM BEGINS --->
<h4>Number4. City info after searching for "s"</h4>
<cfloop index="Counter" from=1 to=6>
<cfoutput>
City: #cityarray[Counter][1]#,
Estate: #cityarray[Counter][2]#,
Code: #cityarray[Counter][3]#,
<!--- I know the findoneof function is not going to help me, but I hope it helps to give you an idea of what I am trying to do--->
#findoneof("sS",cityarray[Counter][1])#
<br>
</cfoutput>
</cfloop>

It is much simpler than you think. Additions and modifications are in italics. Good luck!
<h4>Number2. City info ARRAY contents before appending:</h4>
<cfloop index="Counter" from="1" to="#CityInfo.recordcount#">
<cfoutput>
City: #cityarray[Counter][1]#,
State: #cityarray[Counter][2]#,
Code: #cityarray[Counter][3]#<br>
</cfoutput>
</cfloop>
<!--- #3 I now add/append Irving to the array and change L.A. --->
<cfset cityarray[6][1] = "Irving" />
<cfset cityarray[6][2] = "Texas" />
<cfset cityarray[6][3] = "972" />
<cfset cityarray[4][1] = "Los Angeles" />
<h4>Number3. City info Array contents after adding Irving, TX and updating L.A.:</h4>
<cfloop  index="Counter" from="1" to="#arrayLen(cityarray)#">
<cfoutput>
City: #cityarray[Counter][1]#,
State: #cityarray[Counter][2]#,
Code: #cityarray[Counter][3]#<br>
</cfoutput>
</cfloop>
<br>
<!--- #4 now I look for the 's' in order to add a '!' THIS IS WHERE MY PROBLEM BEGINS --->
<h4>Number4. City info after searching for "s"</h4>
<cfloop index="Counter"  from="1" to="#arrayLen(cityarray)#">
    <cfset sPosition=findNoCase("s",cityarray[Counter][1])>
    <cfoutput>
    City: #cityarray[Counter][1]#,
  State: #cityarray[Counter][2]#,
    Code: #cityarray[Counter][3]#
    </cfoutput>
   <cfif sPosition GT 0><!--- Just display the exclamation mark--->
    <cfelse> <!--- Add whatever you like, or nothing, here--->
    (no 's')
    </cfif>
    <br>   
</cfloop>

Similar Messages

  • How to add a signature at the end of each post

    How do you add a signature at the end of each post (if possible)?
    ^^right now, I just have to copy and paste that

    It's possible to set up your signature on the Desktop such that it can be simply dragged into the Camera icon's "From the Web" field...
    1. Right click on an already posted pic
    2. Choose "Open Link in New Tab"
    3. From the address bar of that new tab, drag the URL's favicon (little icon) to your Desktop whereupon an "@" icon will be created
    The above only has to be done once, and then to use that image in future posts...
    1. Click the Camera icon
    2. Click "From the Web"
    3. Drag the URL's "@" icon from your Desktop to the URL field and click Insert Image
    And if you want your signature instead of a generic "@" icon, that's possible too:

  • How to add a string at the End of TLFTextField without loosing current text format!

    I have a TLFTextField that loads text from external text file.
    Then a function changes the format of some parts.
    Then as soon as I add a string at the end of my TLFTextField, All previous formatting is lost!
    I use this code to add string:
    myTLF.text += "." ;
    or
    myTLFText.text = myTLFText.text.concat(".");
    Should I use another method??

    pass the text through your formatting function again, or try appendText:
    myTLF.appendText(".") ;

  • I need to learn how to add a page at the end of my video to put credits?

    I am editing for the first time EVER and need to know how to add credits to the end of a video

    There are different ways to add credits. Did you have anything particular in mind?
    You may find some ideas here:
    How to Create Scrolling Movie Credits in Adobe Premiere Pro - YouTube
    https://helpx.adobe.com/premiere-pro/using/rolling-crawling-titles.html
    Creating and Editing Titles

  • How to delete a character at the end of each line in a file

    Hi
    How to remove a character or symbol at the end of each line in a file?
    I am having a file with every end of line conatins special chars @.
    I need to remove or delete that sysmbol from file.
    Regards

    JoeBorland wrote:
    File is large about above 20,000 lines.
    I need to find the optimum solution.
    Like reading a file and find the end of character and writing into a file.
    The above way is correct or any other way?Try it and see. Such a program will only be a dozen lines long.

  • How to add an image at the end of a video?

    I tried following these instructions https://pantherfile.uwm.edu/type/www/116/SoftwareTutorials/QuickTimePro/DougProu ty_QTPro_Tutorial/QuickTimePro_DougProuty.pdf
    But can't find where to choose the frame rate. So when I add it to my video it goes away so quick you can't even read it.
    Can anyone please help me with this.
    Thank you.

    Those instructions are very old and not intended for a single image.
    In your case you need to give your still image some "time" (duration). Easy to do with QuickTime Player Pro.
    Open any audio file in QuickTime, make a selection (in and out points) that matches the duration you wish for the image file. Let's say an mp3 with a ten second selection. Leave this window open.
    Open your image file in QuickTime. Select All (Edit menu) and Copy. Close this window.
    Switch to your audio file selection. From the Edit menu choose Add to Selection & Scale. You'll see the window expand in dimensions as your image is added.
    Open the Movie Properties window (Windows menu). You'll notice it now has a "Video" track.
    Single click on the Video track and then click the "Extract" button (upper left of the window). The ten second video track will open in a new Player window.
    Close the audio file window without saving.
    Do a "Save As" on the image video track. Give this new .mov file a name and location. Leave the window open.
    Select All and copy the ten second video track. Switch to the movie file you want to add it to and move the playhead to the end. From the Edit menu "Paste" the ten second video. It will be added to the end of the movie.
    Save As (self contained) and name the new video.

  • How to add a total at the end of a characteristic column

    Hi All,
    There is a report where sales document number(0doc_number)is displayed in one of the columns,
    now There is a requirement where I need to add a total count of those doc numbers at the end of that column.
    I am not able to find a suitable way to do that.
    I tried exception aggregation for taking a count of doc numbers but that will be another column then while I need the total at the end of the same
    column which already exists.
    Please assist.
    Thanks,
    Dolly

    Hi Suman,
    A part of the report is :
    I need a count as 2 in above example at the bottom of sales document column.
    Dolly

  • How to add a column at the end of table in already designed document..?

    Hi,
    I am writing a javascript for adding a column at the end of table in Indesign document. using our plug-in we have created the Indesign document.
    Each table i want to add one extra column at the end. Is it possible..? please help me if anyone has idea regarding this.
    Thanks,
    Vimala L

    Hi Vimala,
    Please try the below JS code, This code will add the new column in every table last column after.
    var myTable = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
    for(i=0; i<myTable.length; i++){
       myTable[i].columns.add(LocationOptions.after, myTable[i].columns[-1]);
    thx,
    csm_phil

  • How to add a number at the end of a bar chart?

    Hello everyone,
    I am building a series of graphs and bar charts for my thesis.
    I am struggling top fin an option that would allow me to but a "n=number" kind of entry at the end of the chart.
    I did manage to put the percentages in front of every bar, but what I wanted to do is something like this:
    Is this even feasible?
    Thank you everyone for the help!
    Cheers,
    Tiago

    Hello Jerrold
    Thank you very much for the help mate!
    It might take a little longer to edit all the graphs, but it's a start
    Thanks once again!
    Tiago

  • How can I add a character to the end of any text that is entered into a fillable field?

    I am creating a fillable PDF in the form of a business letter.  To start the letter, the form has Dear [fillable field for name].  I need a script that will enter a colon after the person inputs their name.  I have an Acrobat JavaScript scripting reference guide, but do not know where to start.
    Thanks in advance.

    Use this script as the field's custom format code:
    if (event.value) event.value+=":";
    On Wed, Oct 15, 2014 at 9:10 PM, itjmmurray <[email protected]>

  • ADF-BC JSF Counting the number of displayed rows that meet certain criteria

    Hi everyone.
    I have a JSF page that displays a table containing rows with a type attribute that may be either 'A' or 'B'. The page uses an executeWithParams form in order to set query parameters and execute the query. My users have asked me to display percentage information for type A rows at the same page.
    One way to do this would be to create an application module method that would parametrize the query, execute it, iterate through the results, do the calculation and return everything in a formatted string.. Somehow this approach does not seem right.
    Is there a best practice regarding situations like this? Any reference to code example would be perfect.
    Thanassis

    Maybe you can use the getEstimatedRowCount() method on the view.
    See more info here:
    http://download.oracle.com/docs/html/B25947_01/bcquerying006.htm

  • How can I add sales TAX at the end of my calculations?

    How can I add sales TAX at the end of my calculations?

    We currently do not support adding sales tax.
    Randy

  • I made a video in imovie and saved it, now i want to carry on making it from where i left but every time i try to add an image onto the end it just goes tot he wrong part of the movie, how do i just add it onto the end?

    I made a video in imovie and saved it, now i want to carry on making it from where i left but every time i try to add an image onto the end it just goes tot he wrong part of the movie, how do i just add it onto the end?

    Have you seen my User Tipp here
    "Movie Magic" with Stills and Dissolve
    When you 'prep' your stills in any 'picture app', you can do a lot of marvel by simply applying dissolves.
    In your case, I would create a white document (in Pixelmator, Keynote, Photshop, online at pixlr.com, whatever ...) and another with your logo (and further more ones with additional logos). Drag the jpgs into your iMovie Project and apply dissolves  - tadahh! - logos appear on white.

  • How to add new fields in the EBP front end..

    Hi All,
    Can any one let me know the process of how to add new fileds in the shopping cart creation screens by using the "Tag Browser" option in the Object navigator.
    Best Regards,
    Mahesh. J

    Hi
    <b>Please go through the following links for more details and examples -></b>
    http://help.sap.com/saphelp_47x200/helpdata/en/a2/8c6eeb2d8911d596a000a0c94260a5/frameset.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/d3/5ecbe22a8a11d5991f00508b6b8b11/frameset.htm
    This will definitely help.
    <u>For adding customer fields to the Shopping cart, you need to refer SAP OSS Bote 672960 and 485891.</u>
    Do let me know, incase you need any other details.
    Regards
    - Atul

  • Is it possible to export to PDF without a Return character at the end of every line?

    I am the author of a book whose first edition has been typeset and extensively amended in InDesign.  I now need to rewrite the first edition to produce a second edition.
    When I copy-and-paste from the PDF with which the publisher has supplied me into MS Word, I get a Return character at the end of every line, which means that text doesn’t automatically wrap and sentences are fragmented so that I get spurious grammar errors.
    I know that not all PDF files have a Return at the end of every line.  Is it possible to restrict Returns to the end of paragraphs when exporting from InDesign to PDF?  If so, what should the publisher be asking the typesetter to do?

    Thanks for your lightning-swift and helpful replies, Mike & Ellis.
    I don't have InDesign myself, so I know hardly anything about how it's used.  I'm just trying to research what an internationally-known publisher should already know how to do, but apparently doesn't!
    Following your suggestion, Mike, I have downloaded the trial version of Acrobat and exported the PDF to a Word file.  This has been moderately successful as there are far fewer spurious Return characters, just a few that I suspect may be hangovers from the typesetter having introduced soft returns in ID.
    As you've suggested Peter and Ellis, I'll suggest that the publisher asks the typesettter to export from ID to RTF and Text to see if that's even better.
    Message was edited 15:24 GMT by: AlanS5100

Maybe you are looking for

  • HP 6520 won't scan with wireless connection and new router

    My printer scanned fine before.  Got a new internet provider=new router and now I can't scan scan anymore.  The computer is connected wirelessly.  The computer says it cannot communicate with the scanner.  Same if I try from the printer front panel,

  • How to use a case ststement in interface?

    how to use a case statement in interface? My requirement is in interface for one column for Eg: In source column if a.b=c.d then i need to write as "Source" else when a.c=d.e then i need to write as "Target". please can you help in solving this. Rega

  • What format should I import CDs on???

    Hellllllooo I have just started to get into audio quality, and all that sort of stuff... I would like to know what format I should import CDs to my itunes library on, as i have just purchased a pair of high end Sennheiser headphones, and i do not wan

  • Printing takes 2-3 minutes to spool

    I have a Lexmark E250dn printer. It worked perfectly for a long time. But, then it started taking 2-3 minutes for a document to print. It sits there with the message "sending data" and then suddenly prints a few minutes later. I've tried updating to

  • Changes to hierarchy in RSH1

    Hi All, I need to change one of our 0COSTELMNT hierarchies in RSH1, currently the hierarchy is defined using number ranges and I need to extend the number range.  Do I do this directly in client, or is this type of task only to be performed in DEV an