Jump to content

Filling array with strings from a program and use it in another


Recommended Posts

Hello humans!

I wanna inquire about how to fill an array, I only used arrays with "fix" data before. I need to handle a code for a program (lets call it prog A), thats generated from another (prog B ). The catchy part is, that all these code from B is usuable only once by A. I'm confident that I can write a script that generate these codes, my problems lies in store them well and intelligently. I thought about an array with a $variable for array size (I think that can be done with a global array right?) like Global $dataarray[$variable], this $variable starts at 1, and with every iteration we add +1 to it.

With this approach I have a dynamicly growing array, when the function for harvesting the data is ended (at 50 for example, or when user interrupt it). I'm not sure after that, how can I delete from this array, when the script "use up" a code, should I somehow decrese the array size as well? I don't think its a good idea, at least it doesnt sound that to me.

I know that you guys don't really like questions like these, since a) it must have been asked somewhere already b)I don't have any code yet.

Well a) is true for almost every question in this forum :) b ) I start working right now on the function and I will keep this thread updated, I just want to save time for myself, since I won't likely be able to solve this alone, I dont wanna sit at the computer waiting to someone to help me while I can't do anything. I hope you can forgive me this selfishnes, and thank you for your help guys!

Have a nice life!

Novice SorryButIma....

Edited: for B) to b )    :)

Edited by SorryButImaNewbie
Link to comment
Share on other sites

This is not a complete thing but I feelt bad  not posting any code, so here is where I'm at right now, also it may give some insight on what I'm doing

Func Adattoltes()
    Local $StartFileSelectFolder = FileSelectFolder("Adja meg az UD_uszi.exe helyét!", "")
    Run($StartFileSelectFolder & "\UD_uszi.exe")
    Sleep(3000)
    WinWaitActive("UD ÜSZI")
    ControlSetText("TLoginForm", "UD ÜSZI", "TEdit2", "BALAZSGE")
    Send("{TAB}BALAZSGE")
    Sleep(50)
    Send("{ENTER}")
    WinWaitActive("UD Üszi - verzió")
    Local $handle = WinGetHandle("UD Üszi - verzió")
    Local $1 = 1
    While $1 = 1
        ControlClick($handle, "", "[CLASSNN:TAdvBitBtn13; TEXT:Teszt - Útdíj fizetés adhoc előkészítés]")
        WinWaitActive("Útdíj fizetés adatok")
        Local $handle2 = WinGetHandle("Útdíj fizetés adatok")
        WinMove($handle2, "", 541, 210)
        ControlClick($handle2, "", "[CLASSNN:TAdvBitBtn4]")
        Sleep(200)
        ControlClick($handle2, "", "[CLASSNN:TAdvBitBtn3]")
        Sleep(4000) ;After this button the B program works a bit, dont know better solution for that... anyidea?
        ControlFocus($handle2, "", "TDEdit4")
        Sleep(1000)
        Send("{CTRLDOWN}c{CTRLUP}") ;this somehow doesn't seems to do the trick sometimes, I think a regex can be implemented to check if its a x pices of number or not
        Sleep(200)
        $VJszam = ClipGet()
        Global $arraysize = $arraysize + 1
        If $arraysize = 24 Then $1 = 0
    WEnd

    EndFunc   ;==>Adattoltes

And the global array for now:

Global $VJszam
Global $arraysize = 1
Global $VJszamarray[$arraysize] ;I'm not sure if this can actually work
$VJszamarray[1]
$VJszamarray[2]
$VJszamarray[3]
$VJszamarray[4]
$VJszamarray[5]
$VJszamarray[6]
$VJszamarray[7]
$VJszamarray[8]
$VJszamarray[9]
$VJszamarray[10]
$VJszamarray[11]
$VJszamarray[12]
$VJszamarray[13]
$VJszamarray[14]
$VJszamarray[15]
$VJszamarray[16]
$VJszamarray[17]
$VJszamarray[18]
$VJszamarray[19]
$VJszamarray[20]
$VJszamarray[21]
$VJszamarray[22]
$VJszamarray[23]
$VJszamarray[24]

How can I implement the $VJszam variable to the 1. "socket" of the array then the next $VJszam to the 2. and so on?

Link to comment
Share on other sites

So it says that I exceeded my array range, and I dont understand how here is the script:

Global $iMax = 8

        Global $arr[$iMax] = [0]

        For $i = 1 To 8
            ; Check that the array is big enough
            If UBound($arr) = $i Then
                ; Resize the array when $i is equal to the element count in the array to prevent subscript error
                ReDim $arr[$arr[0] + $iMax]
            EndIf

            $arr[$i] = $VJszam ;& $i ; safely add data to new index element

            $arr[0] = $i ; update the index count for future reference
        Next

        ReDim $arr[$arr[0] + 1]


        MsgBox(0,"Semmi","$arr[" & $i & "]:=" & $arr[$i])

I copied it from the Wiki page so I'm not sure what the problem could be

Link to comment
Share on other sites

Here is my full function, but it refills the entire array with the same data, I would like it to fill the first array "socket", then in the next loop fill the next one 

Func Adattoltes()
    Local $StartFileSelectFolder = FileSelectFolder("Adja meg az UD_uszi.exe helyét!", "")
    Run($StartFileSelectFolder & "\UD_uszi.exe")
    Sleep(3000)
    WinWaitActive("UD ÜSZI")
    ControlSetText("TLoginForm", "UD ÜSZI", "TEdit2", "BALAZSGE")
    Send("{TAB}BALAZSGE")
    Sleep(50)
    Send("{ENTER}")
    WinWaitActive("UD Üszi - verzió")
    Local $handle = WinGetHandle("UD Üszi - verzió")
    Local $1 = 1
    While $1 = 1
        ControlClick($handle, "", "[CLASSNN:TAdvBitBtn13; TEXT:Teszt - Útdíj fizetés adhoc előkészítés]")
        WinWaitActive("Útdíj fizetés adatok")
        Local $handle2 = WinGetHandle("Útdíj fizetés adatok")
        WinMove($handle2, "", 541, 210)
        ControlClick($handle2, "", "[CLASSNN:TAdvBitBtn4]");basicly generate the code we need, forgot to mention it at 1. post, sry
        Sleep(200)
        ControlClick($handle2, "", "[CLASSNN:TAdvBitBtn3]")
        Sleep(4000) ;After this button the B program works a bit, dont know better solution for that... anyidea?
        ControlClick($handle2, "", "[CLASSNN:TDEdit8]", "", 1, 320, 10)
        Sleep(200)
        ControlClick($handle2, "", "[CLASSNN:TDEdit8]", "", 1, 300, 15)
        Sleep(200)
        Send("{DOWN}")
        Sleep(200)
        Send("{ENTER}")
        Sleep(200)
        ControlFocus($handle2, "", "TDEdit4")
        Sleep(1000)
        Send("{CTRLDOWN}c{CTRLUP}") ;this somehow doesn't seems to do the trick sometimes, I think a regex can be implemented to check if its a x pices of number or not, ControlGetText seems to be worst
        Sleep(200)
        Global $VJszam = ClipGet()

        If StringRegExp($VJszam, "(\d{11})", $STR_REGEXPMATCH) = 0 Then 
            WinActivate($handle2)
            Sleep(200)
            ControlClick($handle2, "", "[CLASSNN:TDEdit4]", "", 2)
            Send("{CTRLDOWN}c{CTRLUP}")
            Sleep(400)
            Global $VJszam = ClipGet()
        EndIf

        Global $iMax = 8

        Global $arr[$iMax] = [0]

        For $i = 1 To 8
            ; Check that the array is big enough
            If UBound($arr) = $i Then
                ; Resize the array when $i is equal to the element count in the array to prevent subscript error
                ReDim $arr[$arr[0] + $iMax]
            EndIf

            $arr[$i] = $VJszam ;& $i ; safely add data to new index element

            $arr[0] = $i ; update the index count for future reference
        Next

        ; Adjust the array size. This time it is probably downward to the size of
        ; $arr[0] + 1 (remember the first item is $arr[0])
        ReDim $arr[$arr[0] + 1]


        For $i = 1 To $arr[0]
            ConsoleWrite("$arr[" & $i & "]:=" & $arr[$i] & @LF)
        Next

        ControlClick($handle2, "", "[CLASSNN:TAdvBitBtn1]") ;Rendben gomra kattintás
        WinWaitActive("Kérdés", "", 5)
        If WinWaitActive = 0 Then
            WinActivate($handle2)
            ControlClick($handle2, "", "[CLASSNN:TAdvBitBtn1]")
            WinWaitActive("Kérdés", "", 5)
        EndIf
        Send("{TAB 4}{ENTER}")
        Sleep(200)
        WinActivate("UD Üszi - verzió")
    WEnd
EndFunc

it opens the prog b , with help of the user (it can be in different places in different PCs) then start the loop which i try to make so it fills the array, these data will be used in many other functions thats why most variables are global

Edit: Took out comments written in my mother language, it wouldn't help you guys much :)

Edited by SorryButImaNewbie
Link to comment
Share on other sites

I think I will open a new thread because this one is too long for any casual helper to read it, now I realize that on the idea of constant update in a forum like this isn't going to work this way, and my very idea of it was broken from the start  :sweating:  sorry for that.

Edit: I mean by a forum like that, that anyone who would like to help needs to familirize himself with the situation and the task at hand and then think a solution to add to the thread, both take a considerable amount of time (longer and longer as i update, making the information on the first posts essentialy useless). So even if someone took the time, ignore the obvius frustration, and bother to help I could be very well on some other problem.... So again sorry for that, this is basicly my first account in any forum I think, and I need time to get used to it

Edited by SorryButImaNewbie
Link to comment
Share on other sites

  • Moderators

Locked at OP's request.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...