Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2

    Unanswered: Adding A Simple Counter

    Greetings,
    This is a very basic request for help but after searching and attempting to define a simple counter is proving to be a wasted effort therefore I am seeking guidance from this community. I have a 'For Each...' command in a program and it is looping through just as it should; however, for testing purposes, I want a message to appear every time the program completes a loop - so far, this much works. What I cannot seem to do is add a variable that can count/increment the number of loops. I have tried adding this simple variable (count=count+1) but I can find no means to add it. The user guide shows an example like this:

    For Each Record from [$rset]
    Simple Math: [FieldA]=[FieldA]+1
    Next Item

    It looks deceptively simply but I am having zero success in adding this variable. How can I add this 'Simple Math'? I have seriously attempted all options in the 'Script Designer' for 'Add Variable' that I can find and I cannot even add '1' to a number. Please help...

  2. #2
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    If you post the bit where you try this, it may help someone help you.

  3. #3
    Join Date
    Sep 2011
    Location
    Australia
    Posts
    264
    Provided Answers: 2
    Assuming you have created a global "maths" variable call count and placed it inside the loop , it should be possible to display this variable with a "calculated mathematical" field on a form - may need to add a "refresh field" action at end of script to update display.

  4. #4
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2
    tamcind,
    What/where is this "calculated mathematical" field that you mention? I do not need to have this appear on a form, I just want to script to count the number of times the program loops based on the "For Next...' statement. The code in my problem is not any different than I posted in my example. All I need to know is how to simply add a counter (count=count+1). I can 'almost' create the variable, the issue is I cannot find a way to just add one to that variable. The counter should appear in the script but how does a person add a basic math formula to the script??? Nothing I tried would allow this.

    Please do not read too much into this question because it IS as basic as it appears... I need to add a value of 1 to a variable. I saw many example in the user's guide that involve these basic math functions (+,-,*, and /) but I cannot find where to create the formula. Presumably, I would go to the 'Script Designer', click 'Add Variable' (this would be in between the 'For Each... and Next' statements. Then, on the 'Enter the variable name', click 'Ok', on the 'Set Var by Math Formula' field select the 'Formula to Use' field, and add the simply formula but nothing is there for the basic math functions.

    Thanks,
    Daryl G

  5. #5
    Join Date
    Jul 2012
    Posts
    94
    Provided Answers: 4
    Is this what you want?
    Select more than one record and pres button.
    Attached Thumbnails Attached Thumbnails counter.png  
    Attached Files Attached Files

  6. #6
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2
    MacHeuS,
    Yes, you are right!!! That simple code is exactly what I was asking about. Unfortunately, I cannot open the file you attached (it shows an error of 'Unknown Format'). How/where did you go to add line 4 of your code? I know that this sounds too simply but I cannot find any means to add a simple line like [count]=[count]+1.
    As always, I certainly appreciate your help.
    Thanks,
    Daryl G

  7. #7
    Join Date
    Dec 2012
    Location
    Huntsville, AL
    Posts
    379
    Provided Answers: 2
    MacHeuS,
    Okay... I finally was able to make it work. That proved to be an extremely difficult endeavor for such a simple task. I would have thought that there was a much easier way (i.e., more straightforward) than what was actually required.
    Thanks,
    Daryl G

Posting Permissions

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