Jump to content

How can I save data out of a loop before the loop iterates. - (Moved)


Kruxe
 Share

Recommended Posts

Hey Guys! 

I was hopping I could get some help on this topic, I will try to explain what i am trying to do as clearly as I can!

In a nutshell, I am using the API a program and attempting to find all of the "TRACE FIELD" objects within its active page. using the code you see below i can do just that, upon executing the code the For loop will run over and over, going through each trace field and grabbing the text in each one until there are none left.  My question is how could I take the text from each instance and save it into either individual variables or one large variable that houses all the data before the look resets and wipes the text from the previous iteration?  I hope this made sense, thanks in advanced guys! 

Kruxe 

image.png.f81f67cb31b405e2d99207db9eb42c30.png

 

 

Link to comment
Share on other sites

  • Developers

Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states:

Quote

Share your cool AutoIt scripts, UDFs and applications with others.


Do not post general support questions here, instead use the AutoIt Help and Support forums.

Moderation Team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Just put the $Tracefields into a 1D array that you increment at every find.

I would have given you an example, but with an image, I did not have the courage of rewriting your script.

Next time, please use this tool, when you post code...

Edited by Nine
Link to comment
Share on other sites

Local $DmisApp = ObjCreate("PCDLRN.Application")
Local $DmisActivePartProgram = $DmisApp.ActivePartProgram
Local $DmisCommands = $DmisActivePartProgram.Commands
Local $CommandCount = $DmisCommands.Count
Local $DmisCommand = $DmisCommands.Item($CommandCount)





For $DmisCommand In $DmisCommands

    If $DmisCommand.Type = "191" Then

        $Tracefield = $DmisCommand.GetText(258,0)

        MsgBox("","",$Tracefield)

    EndIf

        

Next

@Nine sorry about that, still very new here. Here you go!

Link to comment
Share on other sites

Try this :

#include <Array.au3>

Local $DmisApp = ObjCreate("PCDLRN.Application")
Local $DmisActivePartProgram = $DmisApp.ActivePartProgram
Local $DmisCommands = $DmisActivePartProgram.Commands
Local $CommandCount = $DmisCommands.Count
Local $DmisCommand = $DmisCommands.Item($CommandCount)
Local $aResult[$DmisCommand], $iCount = 0

For $DmisCommand In $DmisCommands
  If $DmisCommand.Type = "191" Then
    $Tracefield = $DmisCommand.GetText(258, 0)
    $aResult[$iCount] = $Tracefield
    $iCount += 1
  EndIf
Next
Redim $aResult[$iCount]
_ArrayDisplay ($aResult)

 

Edited by Nine
Link to comment
Share on other sites

@Nine Good Morning,

 

I Tried to run the code you provided but i received this message...

==>Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$aResult[$iCount] = $Tracefield
^ ERROR

 

any idea why that is?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...