Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2

    Unanswered: 'If' scripting not working properly

    I realize that there are some other problems with the attached scripting but I am having trouble with the ‘If’ statement. Please focus your attention on lines 4 through 15. I want to compare the names on two different folders using two ‘For Each’ commands – these two ‘For Each’ statements cycle through the names just like I need. When a match is found AND when another field has a value of 1, I want to do something (actually, I want to remove that particular record from the recordset). The problem is that the ‘If’ statement does not recognize this as a match when both names match and the other field is a ‘1’ – the program currently identifies a match as whenever the name on the inner ‘For Next’ statement has a value of ‘1’ regardless of the name on the outer 'For Each'. See screenshot below because this is where the program first stopped at (clearly, the '$name_from_completed' value is not the same as '$name_from_all_employees' though this was the first occurrence where the program encountered the '$inactive_status' of '1'). Why is the scripting interpreting the value in '$name_from_completed' (Greene Daryl R) to be the same as the value in '$name_from_all_employees' (Johnson Greene Lynn)?

    Later, once this issue is corrected, I have to also correct the value in '$original_completed' as I wanted to have a temporary storage location for the original value... but before I go there, I need to understand why the 'If' statement is not operating properly. Any help will be greatly appreciated.

    There is possibly a much better and efficient way to accomplish this - if you have any ideas, please share them!

    [edit] I went back and took out the second rule in the 'If' statement (And [$inactive_status] =1) and just like I assumed, the program identified a match to be between any two names regardless of whether an actual match existed. Why is the program seeing a match between all names when a true match does not always exist?[/edit]
    Thanks,
    Daryl G
    Attached Thumbnails Attached Thumbnails if command problem.jpg  
    Last edited by fireant911; 02-21-13 at 11:55.

  2. #2
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2
    A better question may be: is it possible to set up an 'If' statement with two text variables? I have tried several other approaches to this quandary and I cannot seem to get past this... I believe that the program may be interpreting my earlier 'If' statement as a number rather than the actual variable that it is (this is why it seems to fail does execution - it views '$name_from_completed' = ''$name_from_all_employees' as 0=0). I really need to compare two variable but I do not see a way to do this in Brilliant Database. Surely, this request is not unreasonable as comparing one variable to another is a very common thing - why can I not do this in BD? Help!!!
    Thanks,
    Daryl G

  3. #3
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2
    I am confused. I tried using VBScript to perform this simply line of code (see below):

    Execute VBScript (if name_from_completed=name_from_all_employees and inactive_status=1 then msgbox "stop")

    Not surprisingly, this worked properly and exactly how it is supposed to (when cycling through the nested 'For Each' statements, it stopped whenever the statement is true yet BD does not for the same command written in BD script). Why does Brilliant Database NOT recognize the variables when the statement is true?

    Can someone explain to me why this is happening and how to overcome this issue?
    Thanks,
    Daryl G

  4. #4
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2
    My confusion grows. I discovered a new command on the 'If' statement using formulas, well, I did not just discover it as I had seen it before but did not understand the usage of this. This morning I thought that I finally had this figured out as I set up a formula that looked like it would capture exactly what I needed but when I set up the first formula (see screenshot below) it, TOO, does not recognize cases when the two variables are identical. I can see when I am debugging the script that the values are the same, the VBScript recognizes also that the values are the same, but Brilliant Database does not. Could some please assist me on how to compare two variables?
    Thanks,
    Daryl G

    [edit]I realized that my scripting was not quite right as the equation should be set equal to 1: If If ([name_from_completed],|equal|,[name_from_all_employees])=1 but that did not work either as the program considered all combinations to be a match. I re-modified the script again to use a variable (If If (V([name_from_completed],|equal|,V([name_from_all_employees])=1) and this did not work either because the program still interprets everything as a match. I have exhausted all things I know to do in order to make this work but I cannot make it right. Please, please help.[/edit]
    Attached Thumbnails Attached Thumbnails equal command.jpg  
    Last edited by fireant911; 02-22-13 at 10:21.

  5. #5
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2
    I have spent hours since my last posting looking deeper into this program as well as reading the user's guide. I am amazed at the depth of some of the functions; however, I am really surprised that I cannot find anything that will work when comparing one text variable to another text variable. Whenever I think that I have found something that will work, once I add this to the scripting I quickly see that the program still does not recognize the variable as a text variable (although it does show the proper text value when debugging)... why does the program still view the text variables as simply a value of 0? Please, please help... how can I compare one text variable to another text variable?
    Sincerely,
    Daryl G

  6. #6
    Join Date
    Sep 2011
    Location
    Australia
    Posts
    264
    Provided Answers: 2
    Hi
    If any help have rough example of matching fields in two forms and folders. Appears to work as intended - find first name in contact 2 that matches contact 1 with "M" in field.

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I'd check any documentation on string comparisons. I don't know anything about Brilliant DB, but sting matching can be tricky and quite often you have to use specific functions
    I'd rather be riding on the Tiger 800 or the Norton

  8. #8
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Information overload.
    I'm unsure what your problem is because of all the different information given.

    why does the program still view the text variables as simply a value of 0? Please, please help... how can I compare one text variable to another text variable?
    I'm unsure of what your doing so please see attached file.

    If you type something into the two fields and you press the “Set Var” button. The contents of the two files are then stored in two variable.

    For this example I've also included a tick box. Even if the two fields match, no match will be found unless the tick box is ticked ( a value of 1)

    Press GO to compare the two variables against each other, and to check of the tick box is ticked.

    If the two variable match, but the tick box is unticked, no match will be found.

    If the two variables match and the tick box is ticked, a match will be found.

    If the tick box is ticked, but the variables don't match, no match will be found.

    Regards
    James
    Attached Files Attached Files

  9. #9
    Join Date
    Sep 2011
    Location
    Australia
    Posts
    264
    Provided Answers: 2
    Uploaded Match.zip referred to in previous post-may give you more ideas.
    Attached Files Attached Files

  10. #10
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2
    James,
    Thanks, but it does not work. If both variables are the same and the checkbox marked, it works: however, changing one of the variables to anything else and leaving the checkbox marked, the message still says a match was found.

    Because of this, I think that the program is still not recognizing the variables (hence, my comments about the program interpreting the variable fields as a value of 0 rather than the variable actually contained in the field). It appears that the program is expected a numerical value and since the field is text, it treats the value as 0.

    If you change one of the fields to something else, are you not seeing the same incorrect answer as I am? - see attached screenshot.
    Thanks,
    Daryl G
    Attached Thumbnails Attached Thumbnails james.jpg  

  11. #11
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2
    tamcind,
    Yes, that is it! It worked. Now, I am really curious because the actual 'If' statement you used was MUCH, MUCH simpler than the myriad of versions I attempted. Surely, I would have tried that direct approach... maybe I typed something in incorrectly when I tried that earlier??? Regardless, what you suggested worked perfectly.

    This brings up another question though. Why would using 'formulas' and math/logic functions not work? Well, I should not ponder over such things because I am two and a half days behind now because of this latest problem!
    Huge Thanks,
    Daryl G

  12. #12
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Quote Originally Posted by fireant911 View Post
    James,
    Thanks, but it does not work. If both variables are the same and the checkbox marked, it works: however, changing one of the variables to anything else and leaving the checkbox marked, the message still says a match was found.

    Because of this, I think that the program is still not recognizing the variables (hence, my comments about the program interpreting the variable fields as a value of 0 rather than the variable actually contained in the field). It appears that the program is expected a numerical value and since the field is text, it treats the value as 0.

    If you change one of the fields to something else, are you not seeing the same incorrect answer as I am? - see attached screenshot.
    Thanks,
    Daryl G
    Hmmm... it works, but I just noticed if I close down the database and open up again it doesn't work then.

    OK... that's because of the fact the variable is being set by one button and it's not set as a GLOBAL variable.

    Local variables only work within the script your writing them into.

    For example, here's the exact same database, exact same code, exact same local variable. I simply took the two lines from the Set Var button and added them to the start of the check button. No other changes were made, and now it works all the time.

    Regards
    James
    Attached Files Attached Files

  13. #13
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2
    Thanks James. I looked at your latest attachment but, unfortunately, it still does not work (if I change the text of one of the variables, it still indicates that a match exists). Is anyone else experiencing the same results?

    I am doing a bit of introspection here with the solution. I know that I had previously tried the solution that tamcind recommended - that would have been the most logical approach (that, plus I have a limited amount of BD tricks to use since I am so new to this - I would have certainly tried this first!). I still cannot figure out why this did not work for me earlier... Both variables that I used were all defined as local, and, after all this trouble, it simply took a If [$name_from_completed] = "[$name_from_all_employees]" And [$inactive_status] = 1 then to fix this.

    Here is another question for you: Is it possible to Set Field Value of a field remotely (i.e., can I change the field of one folder while executing the script in another folder)?
    Daryl G

  14. #14
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Try this.
    I think I have it now.

    Regards
    James
    Attached Files Attached Files

  15. #15
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Yep, defiantly working now.
    Here's it working with 3 variables of the exact same name as your looking for.

    Regards
    James
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •