Checking last character

What would you consider being the best way to check the last character of a string?
var folderPath = '~/Desktop/Test';
if (folderPath[folderPath.length - 1] !== '/') { folderPath += '/'; }
  or
if (folderPath.slice(-1) !== '/') { folderPath += '/'; }
I see that changePath() can also be used to keep track of this path separator.
Thanks.

Hi Hans,
I was trying to come up with a function to move a folder and it's contents, or a file... similar to how the OS X Finder would do it.  However, I just noticed when the files are copied over, they're not the same file size as the original which makes me think it's stripping resource forks, etc.  :-(
I'm looking now at using doScript and running ditto from the command-line with applescript.  Here's the code I was working with earlier though:
function moveItem(oldPath, newPath) {
    newPath = newPath.toString();
    //if (newPath[newPath.length - 1] !== '/') { newPath += '/'; }
    if (newPath.slice(-1) !== '/') { newPath += '/'; }
    var oldPathType = oldPath.constructor.name;
    if (oldPathType === 'Folder') {
        newPath += (oldPath.name + '/');
        with (Folder(newPath)) {
            if (! exists) { create(); }
        for each (var i in oldPath.getFiles()) {
            if (i.constructor.name === 'Folder') {
                moveItem(i, newPath);
            } else {
                i.copy(newPath + i.name);
                i.remove();
        oldPath.remove();
    } else if (oldPathType === 'File') {
        oldPath.copy(newPath + oldPath.name);
        oldPath.remove();
    } else {
        throw 'Problem moving file/folder!';

Similar Messages

  • Downloading ALV to EXCEL - in some fields the last character is missing ...

    Hi,
    I am experiencing this kind of problem when downloading ALV report into Excel :-
    "You are downloading an ALV result to an EXCEL file. In some fields the last character is missing."
    For example, if MATNR is 0000234567 in display but after downloading to excel it becomes only 23456.
    I found another related forum thread : Pronlem while downloading ALV grid to excel
    I tried the suggested method to apply OSS note 1075315. However, the note cannot be implemented in the system. I am working in a ECC6 environment (SAP version 700, 701).
    Kindly please help me if you came across the similar kind of issue. Thanks much.

    Hi gkGoh8     ,
    The link thread that you just gave already provided the answer, in your field catalog you need to activate field lzero.
    1. Check FM : REUSE_ALV_GRID_DISPLAY
    2. Import Parameter tab :IT_FIELDCAT
    3. Double click SLIS_T_FIELDCAT_ALV
    4. On type group SLIS, check line 93
    Regards,
    JQC

  • Why does Preview automatically resize the text box to cut off the last character of added text? How do I fix it?

    Why does Preview automatically resize the text box to cut off the last character of added text? How do I fix it?
    I use the Tools > Annotate > Add Text feature, and when I click away after adding text, it automatically changes the text box size such that the last letter -- or last word -- gets bumped off into an invisible line below it, forcing me to manually adjust every single text box. It is highly annoying when trying to complete PDF forms (e.g. job applications).
    It appears to be a glitch, quite honestly, an error resulting from Apple's product design. Has it been fixed in the new operating system (for which they want $30)?
    I would very much appreciate any help you can provide! Thank you for your time.

    * "Clear the Cache": Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    * "Remove the Cookies" from sites that cause problems: Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]

  • Testing the last character of a string using .endsWith

    Hi,
    I want to check to see if the last character of a string is '@'.
    I tried if (StringAt.endsWith("a")) {
    but got no results.
    Is this the correct way to do it or is there another way.
    Thanks.
    Adam

    javadocs:
    String's endsWith method takes a string argument.
    endsWith
         public boolean endsWith(String suffix)
              Tests if this string ends with the specified suffix.
              Parameters:
                   suffix - the suffix.
              Returns:
                   true if the character sequence represented by the argument is a suffix of the character sequence
                   represented by this object; false otherwise. Note that the result will be true if the argument is the
                   empty string or is equal to this String object as determined by the equals(Object) method.
              Throws:
                   NullPointerException - if suffix is null.

  • Bi publisher report, data table, column label displays last character

    Hello all,
    I have created various reports on BI Publisher (win2008 R2 64bit 11g (.1.1.5) version). After altering some access rights, all the reports that include data tables display only the last character of the column label. All the column data is reported correctly.
    example:
    - TotalNumber -
    4234
    234
    4
    became
    - r -
    4234
    234
    4
    Any ideas about what is going on???
    Thank you

    Thanks for the suggestion Simon.
    I just created a view based on the 46-column SELECT statement from dual above and then set "SELECT * FROM myview" as the Source Query.
    Unfortunately I get exactly the same error.
    Thanks,
    Andy

  • Last Character In Crystal Report cut off when ran via BO web interface

    I created a report in Crystal and uploaded it to the Business Objects Web Interface.
    On my detail row, the last character is getting cut off regardless of the length of the text.  Even short words like "Yes" are losing the last character, and appearing as "Ye", and there is plenty of room available between the right margin.
    The column header extends out further with no issues.
    Does anyone have a solution for this?

    Hi Dean,
    Try with this:
    Go to the following registry sub key:
    HKEY_USERS\[your security profile]\Software\Crystal Decisions\10.2\Crystal Reports\Export\Pdf
    Right-click the sub key and click New > DWORD Value. Name the DWORD value "ForceLargerFonts" and set it to the value of 1.
    Regards,
    Shweta

  • How can I stop the last character of my password from being displayed?

    Sorry, I'm sure this would have been asked before, but I couldn't locate it..
    When unlocking my iPad, how can I stop it from displaying the last character of my password to everyone in the vicinity? This has got to be the fastest way to find out someone's password (just look at the screen as they type their 'secure' password!?). Having the iPad display your password letter by letter is really not acceptable when working in a non-secure environment.
    Is there a setting somewhere, or will this be addressed in a new iOS, or just ignored as a 'that's the way it is'?
    Thanks in advance,
    Andy

    AdventureBear wrote:
    Hi,
    This may have been the way it has been on iOS since 2008 (not sure about that though), however I know (based on working in the IT industry for 20 years) that nobody on this planet can successfully argue that it would be 'acceptable security practice', for me to display 'every last letter' as I type of a secure 'root' password on my screen every day when you log in... Nobody would think it acceptable to display even their LAN/Domain password on the screen in this same manner. So why is iOS different?!
    iOS on a phone (it used to be argued) doesn't need to be very secure as it is almost entirely phone numbers and email addresses that are being stored. However in recent years when the applications got better, and tablets came out, security became a much bigger issue as more and more people started using the functions of 'smart' phones to store more 'sensitive' data.
    Kind regards,
    Andy
    Are you suggesting that someone looking over your shoulder can't see the keys that you're tapping with your fingers? In the interest of security, i would never, under any circumstances, enter a password when others are around.

  • Truncating last character in a string

    I am making a dialpad. It is just for display so I am using a
    string for the numbers selected. I am trying to make a back button
    that would clear the last number added. I tried mystring.length-1
    but that doesn't seem to be doing the trick. Is there a simple way
    to truncate the last character in a string, of variable
    length??

    Here's an example
    var someStr="asdfasdf saf asdf sadfas dfs fsa asf";
    while (someStr.length) {
    someStr = someStr.substring(0,someStr.length-1)
    trace(someStr);
    }

  • Simulation Capture Problem CP4 - last character in text box cut off.

    This is somewhat difficult for me to explain, but here is what we are experience. The issue we are having is when capturing a demonstration or simulation of our Windows based form in Captivate 4, occasionally the last character of text in a text box field appears to be cut off unless an extra space is added after the character. However, after advancing to the next field in the capture, the complete text does appear in the previous field. So it is actually capturing the text but for some reason it is not showing on the previous slide capture when that text box is active. We are capturing at a resolution of 1024x768.
    Has anyone experienced this behavior? If so what was the solution?
    Thank you.
    Kyle

    Hi Kyle,
    Yes, I have seen this one numerous times. Sometimes I find that pressing the Print Screen key after I have finished typing can help ensure that all the  characters are captured correcty. Pressing the PrntScn enables you to capture manually and is something that many Captivate users prefer to do rather than rely on Captivate's automatic capture engine.
    To be fair, if you own Adobe Captivate 4, then you might find that the new Capture interim screenshot feature (located in the Preferences dialog) might capture all the text for you automatically. Though I have to say that I still prefer to press PrtScn just to be on the safe side.
    HTH
    Best - Mark

  • Character mode report cuts off last character on a line

    Reports 9i, Windows 2003 Server. Printing character mode reports to IBM 6400 printer. I have a variable text column (multi line) and randomly the last character on a line gets cutoff. I'm using Courier 10 as my font. It is only 1 character that ever cuts cutoff. Any ideas? I'm desperate.
    Tom

    Hi,
    change the reports height& width for landscape /portait.
    and go to edit margin in layout.
    see the layout and move to left if it has lot of gap in left side.
    we can get correct output if the right side border is upto 8.2.
    try with this.
    --Basava.s                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to check last log backup happend in sql server

    Hi All,
    How to check last log backup happend in sql server
    Thanks in advance
    Shashikala

    Last Tlog Bakcup details
    SELECT
       CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS Server,
       msdb.dbo.backupset.database_name,
       MAX(msdb.dbo.backupset.backup_finish_date) AS last_db_backup_date
    FROM   msdb.dbo.backupmediafamily
       INNER JOIN msdb.dbo.backupset ON msdb.dbo.backupmediafamily.media_set_id = msdb.dbo.backupset.media_set_id
    WHERE  msdb..backupset.type = 'L'
    GROUP BY
       msdb.dbo.backupset.database_name
    ORDER BY
       msdb.dbo.backupset.database_name
    --Most Recent Database Backup FULL for Each Database
    SELECT 
       CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS Server,
       msdb.dbo.backupset.database_name, 
       MAX(msdb.dbo.backupset.backup_finish_date) AS last_db_backup_date
    FROM   msdb.dbo.backupmediafamily 
       INNER JOIN msdb.dbo.backupset ON msdb.dbo.backupmediafamily.media_set_id = msdb.dbo.backupset.media_set_id 
    WHERE  msdb..backupset.type = 'D'
    GROUP BY
       msdb.dbo.backupset.database_name 
    ORDER BY 
       msdb.dbo.backupset.database_name
    http://www.mssqltips.com/sqlservertip/1601/script-to-retrieve-sql-server-database-backup-history-and-no-backups/
    Database -- > Right click -- > Properties -- >
    Raju Rasagounder Sr MSSQL DBA

  • Check last letter in a string

    Good Day All,
    I have a string field that does not a Consistence length.
    I want to check the last of this field and concatenate some text depending on the result.
    I've tried this but does not work.
    if mid({usp_wb_Reporting_AssetsUnderManagement_A2a_Main;1.account_long_name,1 Len{usp_wb_Reporting_AssetsUnderManagement_A2a_Main;1.account_long_name}-1) = "M"
    then {usp_wb_Reporting_AssetsUnderManagement_A2a_Main;1.account_long_name} & " Managed"
    else {usp_wb_Reporting_AssetsUnderManagement_A2a_Main;1.account_long_name} & " Unmanaged
    Basically I'm check the length and if return an M it's Managed everything else is Unmanaged.
    Thanks
    DM

    if you want to check last letter then try this
    if right({usp_wb_Reporting_AssetsUnderManagement_A2a_Main;1.account_long_name},1)="M" then
    then {usp_wb_Reporting_AssetsUnderManagement_A2a_Main;1.account_long_name} & " Managed"
    else {usp_wb_Reporting_AssetsUnderManagement_A2a_Main;1.account_long_name} & " Unmanaged
    Regards,
    Raghavendra

  • Select from table where last character in string is numeric

    Hello,
    I have a table STREETS with a field called ADDRESS. I would like to select all records from streets where the last character in Address is a number.
    Select ADDRESS from STREETS where regexp_like(substr(address, ?,?,), '[0-9]');
    --? means that I don't know what to put in here!
    I'm not sure if substr is the best approach for this, since i only want the last character and the records are of varying lengths.
    Thanks!

    Hi,
    If you want to use regular expressions:
    WHERE     REGEXP_LIKE ( address
                  , '[0-9]$'
                  )You can get the same results, probably more efficiently, without regular expressions:
    WHERE     INSTR ( '0123456789'
               , SUBSTR (address, -1)
               )     > 0

  • To delete first and last character of a string???

    Hi Everybody !!!
    Do you know a method that can permit to delete in a string the first and the last character?
    For instance I have in my string this word : [the word]
    I would like to delete the '[' and the ']' character.
    Is exist a method that permit to delete this character?
    Thanks !!!

    Look at the substring method of the String class.
    Note that since string is immutable, you'll need to assign the results of substring to a variable (could be the same as the original or different).

  • How to delete last character in a string

    Guys i have a question...
    how can i delete the last character in a string..
    for example
    String myString = "helloWorld, ";
    how do i delete the last character in this string which is a "," ?

    String newString = myString.substring(0, myString.length()-1);

Maybe you are looking for