Page 1 of 2 12 LastLast
Results 1 to 20 of 23
  1. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #1  
    Code:
    found = false; if (arrDBfilename[d] != arrFileSysFilename[f]) { found=true; }
    alert{found}
    ...or...

    Code:
    found = false; if (arrDataBasefilename[d] == arrFileSysFilename[f]) { found=true; }
    alert{found}
    Both code snippets always return "true" for the variable found....

    I've tried enclosing each array variable in String() and appended .toString() to the end of the array variable names.

    Nothing has produced a 'false'....

    what am I missing?

    Palm Pre Backup Utility...done!
    Locate Pre....done!
  2. #2  
    See this thread on the differences between == === != and !==

    http://forums.precentral.net/web-os-...ome-logic.html
    WOG Dev - WebOS Group http://www.WebOSGroup.com
    PMP Dev - http://www.PimpMyPre.com
    Apps: WOG O.S.K., WOG Card Keeper, WOG Glowstick, WOG Kid Protect, PreLoad, PimpMySounds
  3. #3  
    what exactly is in the variables?

    pimp.. that link isn't working for me

    Edit:
    ok working now
  4. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #4  
    Got the link to work...and I swear I seached for this and found nothing...

    but anyway....

    I've tried, =, ==. ===, !=, & !==

    They all return 'true'

    The variables contain paths ... including filenames.

    ex...

    /directory/path/to/file.txt

    Palm Pre Backup Utility...done!
    Locate Pre....done!
  5. #5  
    Quote Originally Posted by DrewPre View Post
    Got the link to work...and I swear I seached for this and found nothing...

    but anyway....

    I've tried, =, ==. ===, !=, & !==

    They all return 'true'

    The variables contain paths ... including filenames.

    ex...

    /directory/path/to/file.txt
    Put this at the top of your scene

    <div id='debugText'></div>

    put this just after your if statement.

    this.controller.get('debusText').innerHTML += (your first variable)+", "+(yoursecond)+","+found;


    Output the variables and make sure they're strings.
    Use === in your if.
    Let me know what gets outputted.
    WOG Dev - WebOS Group http://www.WebOSGroup.com
    PMP Dev - http://www.PimpMyPre.com
    Apps: WOG O.S.K., WOG Card Keeper, WOG Glowstick, WOG Kid Protect, PreLoad, PimpMySounds
  6. #6  
    Quote Originally Posted by pimpmypre View Post
    Put this at the top of your scene

    <div id='debugText'></div>

    put this just after your if statement.

    this.controller.get('debusText').innerHTML += (your first variable)+", "+(yoursecond)+","+found;


    Output the variables and make sure they're strings.
    Use === in your if.
    Let me know what gets outputted.
    yea i debug the same way... print the variables out right before this is executed. Maybe you need to cast as lower case? because the variable "YES" is not the same as "yes" also one may have a space on the end the other may not. a lot of different things can be happening.
  7. #7  
    Quote Originally Posted by antonio3 View Post
    yea i debug the same way... print the variables out right before this is executed. Maybe you need to cast as lower case? because the variable "YES" is not the same as "yes" one may have a space on the end the other may not. a lot of different things can be happening.
    Ya, my programs are so ugly when I am first making them because I am constantly dumping everything out to the screen. Nice to know someone else is as weird as I am!

    And I was looking at the original code - I'm guessing the [g] and [f] arrary references are var f = some Integer earlier in the function? (g too). I just assumed it was a for loop but if you're comparing undefined to undefined, it'll give you weird results.
    WOG Dev - WebOS Group http://www.WebOSGroup.com
    PMP Dev - http://www.PimpMyPre.com
    Apps: WOG O.S.K., WOG Card Keeper, WOG Glowstick, WOG Kid Protect, PreLoad, PimpMySounds
  8. #8  
    How are you creating the "array" in your example? Is arrDataBasefilename an array or an object?

    Associative arrays are not a part of JavaScript...

    I can't post links yet, but check out the hunlock dot com blog, quirksmode dot org and blog dot persistent dot info site for more information that is very relevant.

    Regarding "===", "!==" vs. "==", "!=":
    The first two are for the case when you want to compare both the type AND value of the variables. The second pair are for comparing the values of variables only. Despite what some people have said on other threads, there is a place for both.

    Hope this helps.
    -Pavan.
  9. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #9  
    I already have the alertMessage popup function below.


    Code:
    MainAssistant.prototype.alertMessage = function(title, message)
    {
    		this.controller.showAlertDialog({
    			onChoose: function(value){
    			},
    			allowHTMLMessage: true,
    			title: title,
    			message: message,
    			preventCancel: true,
    			choices: [{
    				label: $L('Ok'),
    				value: ""
    			}]
    		});
    }
    So when I issue a
    Code:
    this.alertMessage("Filename Compares?", arrDataBasefilename[d] +" = "+arrFileSysFilename[f]+"?  - "+found)
    I get a popup displaying the values of the two referenced array variables. Both of them are different from the other. [I used the 'length' function to make sure there were no white spaces and used 'trim' to make sure] ... Yet the value for 'found' always displays 'true'

    Again, I have tried =, ==, ===, !=, & !==

    Also tried, .value, .valueOf, .toString(), and String().

    ???????

    Palm Pre Backup Utility...done!
    Locate Pre....done!
  10. #10  
    Quote Originally Posted by PavanR View Post
    How are you creating the "array" in your example? Is arrDataBasefilename an array or an object?

    Associative arrays are not a part of JavaScript...

    I can't post links yet, but check out the hunlock dot com blog, quirksmode dot org and blog dot persistent dot info site for more information that is very relevant.

    Regarding "===", "!==" vs. "==", "!=":
    The first two are for the case when you want to compare both the type AND value of the variables. The second pair are for comparing the values of variables only. Despite what some people have said on other threads, there is a place for both.

    Hope this helps.
    -Pavan.
    Good links and information.

    I do use arrays in my apps though.

    this.myValues= new Array("1","2","3","4");

    Can be accessed by this.myValues[0];
    You can also do
    this.myValues = new Array();
    this.myValues["firstVal"]="this values";
    and access it by var someString = this.myValues["firstVal"];
    WOG Dev - WebOS Group http://www.WebOSGroup.com
    PMP Dev - http://www.PimpMyPre.com
    Apps: WOG O.S.K., WOG Card Keeper, WOG Glowstick, WOG Kid Protect, PreLoad, PimpMySounds
  11. #11  
    Quote Originally Posted by DrewPre View Post
    I already have the alertMessage popup function below.


    Code:
    MainAssistant.prototype.alertMessage = function(title, message)
    {
    		this.controller.showAlertDialog({
    			onChoose: function(value){
    			},
    			allowHTMLMessage: true,
    			title: title,
    			message: message,
    			preventCancel: true,
    			choices: [{
    				label: $L('Ok'),
    				value: ""
    			}]
    		});
    }
    So when I issue a
    Code:
    this.alertMessage("Filename Compares?", arrDataBasefilename[d] +" = "+arrFileSysFilename[f]+"?  - "+found)
    I get a popup displaying the values of the two referenced array variables. Both of them are different from the other. [I used the 'length' function to make sure there were no white spaces and used 'trim' to make sure] ... Yet the value for 'found' always displays 'true'

    Again, I have tried =, ==, ===, !=, & !==

    Also tried, .value, .valueOf, .toString(), and String().

    ???????
    When all else fails I use indexOf
    JavaScript indexOf() Method

    I still don't see what the problem is though - sorry!
    WOG Dev - WebOS Group http://www.WebOSGroup.com
    PMP Dev - http://www.PimpMyPre.com
    Apps: WOG O.S.K., WOG Card Keeper, WOG Glowstick, WOG Kid Protect, PreLoad, PimpMySounds
  12. #12  
    Can you post the code before the if statement? The variable declarations and everything? (including found)
    WOG Dev - WebOS Group http://www.WebOSGroup.com
    PMP Dev - http://www.PimpMyPre.com
    Apps: WOG O.S.K., WOG Card Keeper, WOG Glowstick, WOG Kid Protect, PreLoad, PimpMySounds
  13. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #13  
    One array was created as the resultant array of a DB Querey using the
    this
    .db.transaction function. I then looped through that array and created a separate array of one of the columns for FileName.

    The other array was created via looping though another array that was created with the .split function to get a three character length value and then stringing together that value with the known path to the file.[everything in the file and path is known except for those three characters]


    I am pretty sure [but not 100%] that these arrays are not objects.

    But I am relatively a novice at developing.

    Quote Originally Posted by PavanR View Post
    How are you creating the "array" in your example? Is arrDataBasefilename an array or an object?

    Associative arrays are not a part of JavaScript...

    I can't post links yet, but check out the hunlock dot com blog, quirksmode dot org and blog dot persistent dot info site for more information that is very relevant.

    Regarding "===", "!==" vs. "==", "!=":
    The first two are for the case when you want to compare both the type AND value of the variables. The second pair are for comparing the values of variables only. Despite what some people have said on other threads, there is a place for both.

    Hope this helps.
    -Pavan.

    Palm Pre Backup Utility...done!
    Locate Pre....done!
  14. #14  
    Quote Originally Posted by DrewPre View Post
    I already have the alertMessage popup function below.

    I get a popup displaying the values of the two referenced array variables. Both of them are different from the other.
    what do you mean both of them are different from the other?

    for example...

    the first variable = '/directory/path/to/file.txt'
    the second on = '/directory/path/to/filezzzzzzzz.txt'

    so in
    Code:
    found = false; 
    if ('/directory/path/to/file.txt' == '/directory/path/to/filezzzzzzzz.txt') 
    { found=true; }
     
    alert{found}
    This should equal False... those 2 variables do not equal

    The million dollar question is... what exactly do those variables print out? if you were to print them out? And if it's not getting the correct file name maybee we need to look higher up in those db calls.
  15. #15  
    If you tried dumping them to a div using the innerHTML, if it is an object, it would say [OBJECT object] and you could use a for loop like

    for var eachVar in myArr[g]
    blah blah bah
    WOG Dev - WebOS Group http://www.WebOSGroup.com
    PMP Dev - http://www.PimpMyPre.com
    Apps: WOG O.S.K., WOG Card Keeper, WOG Glowstick, WOG Kid Protect, PreLoad, PimpMySounds
  16. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #16  
    When all else fails I use indexOf
    JavaScript indexOf() Method
    Yea, I tried

    Code:
    if (arrDatabaseFilename[d].indexOf(arrFileSysFilename[f])) > -1)
    {
    	found = true;
    }
    ...didn't work either.

    The code for the function looks like this [less a few lines of string manipulation to display the strings as desired which has been visually confirmed by the alertMessage function to be displaying correctly]....


    Code:
    for (f=0;f<arrFileSysFilenames.length;f++)
    {
        for (d=0;d<arrDatabaseFilenames.length;d++)
        {
            if (arrDataBaseFilename[d] == arrFileSysFilename[f])
            {
                found=true;
            }
            this.alertMessage("Filename Compares?", arrDataBaseFilename[d] +" = "+arrFileSysFilename[f]+"  -"+found)
        }
    }
    The loops are cycling correctly, but the if-then test is not performing as expected. I am tempted to wipe my emulator. I suspect something wrong with it.
    Last edited by DrewPre; 03/15/2010 at 07:30 PM.

    Palm Pre Backup Utility...done!
    Locate Pre....done!
  17. #17  
    Your alert is going to show whether they match or not - have you moved it into the if statement to verify that you got a match? I don't see you outputting "found" to say Yes it was a match or no it wasn't.
    Other than that it looks ok..
    WOG Dev - WebOS Group http://www.WebOSGroup.com
    PMP Dev - http://www.PimpMyPre.com
    Apps: WOG O.S.K., WOG Card Keeper, WOG Glowstick, WOG Kid Protect, PreLoad, PimpMySounds
  18. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #18  
    I don't see you outputting "found" to say Yes it was a match or no it wasn't.
    ya, I fixed that....it is there tho..




    Here are screen shots of the alertMessage functions print out....

    Palm Pre Backup Utility...done!
    Locate Pre....done!
  19. #19  
    Quote Originally Posted by DrewPre View Post


    Here are screen shots of the alertMessage functions print out....
    Ya, that's what you'll get every time - you're not outputting the alert only if it's found - you're outputting it for every file in your second array whether it matches or not.

    EDIT:

    Nevermind - now I see it

    You match something at SOME POINT during the loop and found gets set to true.
    Move the alert into the if statement.
    WOG Dev - WebOS Group http://www.WebOSGroup.com
    PMP Dev - http://www.PimpMyPre.com
    Apps: WOG O.S.K., WOG Card Keeper, WOG Glowstick, WOG Kid Protect, PreLoad, PimpMySounds
  20. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #20  
    Thank you... That does it... I also added an else {found = false} statement...that helped.

    I have been over thinking things, I think.

    Palm Pre Backup Utility...done!
    Locate Pre....done!
Page 1 of 2 12 LastLast

Posting Permissions