Another Newbie Question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • SWF
    Forum Member
    • Aug 2003
    • 7

    Another Newbie Question

    I have created (4) buttons and each time a button is clicked it inserts a line into the same text file. (Button 1 insert line at 1, Button 2 insert line at 2 etc...) We found that if you repeatadly click the button it continues to add the line (I did not see an overwrite option when using the insert command).
    Is there a way to make the button dim or change color once it has been executed, or is there a way to make a button execute only once.

    Thank You
  • Corey
    Indigo Rose Staff Alumni
    • Aug 2002
    • 9741

    #2
    Re: Another Newbie Question

    There are many ways but one easy way to set a button to work only once is by using a variable. So on your button put an IF statment, i.e. if %clicked% = no then execute action... Then add a VARIABLE SET VALUE action to set that button, i.e. %clicked% = yes and that button won't trigger any actions after the first time it is clicked...

    Corey Milner
    Creative Director, Indigo Rose Software

    Comment

    • TJ_Tigger
      Indigo Rose Customer
      • Sep 2002
      • 3159

      #3
      Re: Another Newbie Question

      I had to do something like this for the testing application I made. It stores the answers in a global list and I found that when I would navigate from one question to another it would append or prepend the current question answer to the list. This in turn then made the list grow and incorrectly store my information.

      My approach was a little different than Coreys since I was using the global list to store the answer to the question and I wanted the test taker to be able to change the answer they chose. Soooo, what I did was a quick check, where I would gather the question and answer from the page and store it in a variable, If the line in the global list did not match the currently selected question and answer I would remove that line item and then add the current question and answer. If they were the same (i.e., your multiple click action) it would not do anything.

      Here is the code:
      <pre>//Get the currently item in the global list
      %ListItem% = GlobalList[Selected Answers].GetItem (%QuestionsAsked%)
      //Extract the answer portion of the list item
      %NewString% = String.GetDelimitedString ("%ListItem%", ";;", 1)
      //check to see if the new answer is equal to the answer if it is goto skip
      // if not remove the old then replace it with the new.
      IF (%Answer% = %NewString%)
      GOTO ("SKIP")
      ELSE
      GlobalList[Selected Answers].Remove (%QuestionsAsked%)
      GlobalList[Selected Answers].Add (%QuestionsAsked%, "%Question%;;%Answer%")
      END IF
      SKIP</pre>

      I ended up doing it this way so I would not incorrectly grow my global list.

      HTH
      Tigg
      TJ-Tigger
      "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
      "Draco dormiens nunquam titillandus."
      Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

      Comment

      • SWF
        Forum Member
        • Aug 2003
        • 7

        #4
        Re: Another Newbie Question

        Thank you very much

        SWF

        Comment

        • SWF
          Forum Member
          • Aug 2003
          • 7

          #5
          Re: Another Newbie Question

          I am still having trouble &amp; I am sure that it is because I am just plain clueless. This is the action that I have associated with my button.
          <IR_ACTIONS_LIST>
          <Action name="IF">
          <Type>200</Type>
          <Function>1</Function>
          <DTIndentLevel>0</DTIndentLevel>
          <Enabled>1</Enabled>
          <ErrorHandling>
          <UserNotificationMode>2</UserNotificationMode>
          <CustomErrorMessage/>
          <OnErrorAction>0</OnErrorAction>
          <JumpToLabel/>
          </ErrorHandling>
          <Condition>%clicked% = "no then execute action"</Condition>
          </Action>
          <Action name="END IF">
          <Type>201</Type>
          <Function>1</Function>
          <DTIndentLevel>0</DTIndentLevel>
          <Enabled>1</Enabled>
          <ErrorHandling>
          <UserNotificationMode>2</UserNotificationMode>
          <CustomErrorMessage/>
          <OnErrorAction>0</OnErrorAction>
          <JumpToLabel/>
          </ErrorHandling>
          </Action>
          <Action name="Set Value">
          <Type>6</Type>
          <Function>0</Function>
          <DTIndentLevel>0</DTIndentLevel>
          <Enabled>1</Enabled>
          <ErrorHandling>
          <UserNotificationMode>2</UserNotificationMode>
          <CustomErrorMessage/>
          <OnErrorAction>0</OnErrorAction>
          <JumpToLabel/>
          </ErrorHandling>
          <Variable>%Custom%</Variable>
          <Value>%clicked% = yes </Value>
          <Evaluate>0</Evaluate>
          </Action>
          <Action name="Write">
          <Type>32</Type>
          <Function>0</Function>
          <DTIndentLevel>0</DTIndentLevel>
          <Enabled>1</Enabled>
          <ErrorHandling>
          <UserNotificationMode>2</UserNotificationMode>
          <CustomErrorMessage/>
          <OnErrorAction>0</OnErrorAction>
          <JumpToLabel/>
          </ErrorHandling>
          <FileName>C:\KMA Frpo\L.txt</FileName>
          <DataToWrite>!R!
          FRPO L1,00; CMNT "Enter your L1 parameter";
          STAT1;
          EXIT;</DataToWrite>
          <IfFileExists>0</IfFileExists>
          </Action>
          <Action name="Open">
          <Type>7</Type>
          <Function>0</Function>
          <DTIndentLevel>0</DTIndentLevel>
          <Enabled>1</Enabled>
          <ErrorHandling>
          <UserNotificationMode>2</UserNotificationMode>
          <CustomErrorMessage/>
          <OnErrorAction>0</OnErrorAction>
          <JumpToLabel/>
          </ErrorHandling>
          <FileName>C:\KMA Frpo\L.txt</FileName>
          <Verb>open</Verb>
          <WorkingDir>C:\KMA Frpo</WorkingDir>
          <RunMode>0</RunMode>
          </Action>
          </IR_ACTIONS_LIST>

          Comment

          • TJ_Tigger
            Indigo Rose Customer
            • Sep 2002
            • 3159

            #6
            Re: Another Newbie Question

            Download the project listed below. I didn't know exactly where you were getting the information that you are inserting into the text file and where the file is to be stored, but I created a small project to demonstrate a couple of ways you could accomplish what I think you are trying to do.

            Button 1 &amp; 2 work the same where there is a variable %B1Clicked% and %B2Clicked% are set to "NO" in the page settings. If this is NO when you click the button it will then grab text from the edit field box and add it to the appropriate line in the text file (%SrcDir%\scratchpad.txt).

            Button 3 &amp; 4 work the same as well. When you click on them they will get the text you want and place it on the appropriate line. It will then hide the main button and show a disabled button (different color) with a message about it being disabled.

            When you close the application, It will rebuild the text file. I did that so I could test the application again and again without having to rebuild the text file over again. One thing I found is I needed to have multiple lines in the file in order to insert into that position. Just something to keep in mind.

            Click Here

            I hope that this helps. Let me know if you have questions.

            Tigg
            TJ-Tigger
            "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
            "Draco dormiens nunquam titillandus."
            Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

            Comment

            • SWF
              Forum Member
              • Aug 2003
              • 7

              #7
              Re: Another Newbie Question

              Tigg

              Thanks, after looking at your project I discovered in your programing something that worked even better than what I first wanted

              Page.ShowObject=("Button2")
              Page.HideObject=("Button2")

              Then I added a new button
              Page.ShowAllObjects

              Thanks again for showing me a different/easier way to do this

              SWF

              Comment

              Working...
              X