Jump to content

Recommended Posts

Posted

I've been working on a program for a while now to help me with my job in data entry, I'm facing one last issue and I think using an Array might just do the job.

Most of the data I work with contains 1 medical code "example: E11", I made 2 input boxes in my program one for the letter and the 2nd for the number, sometimes i get cases with +2 medical codes, I want a way to put as many medical codes as needed before I run the program.

A little more explanation:

I get a case with 1 medical code, i enter it in my program then run it, the program then enters the needed information plus that code, if i get 2 medical codes, I have to wait for the program to finish it work then enter the 2nd code manually, I added a little button that when clicked will do the part of the program where it enters the medical codes so that way i only have to enter the 2nd code and click the button (without using my program i have to wait for 4 loading screens).

Here is what I came up with so far:

Local $finalMC1 = GUICtrlRead($Medical)
Local $finalMC2 = GUICtrlRead($Medical2)
 
Global $MC[1][2] = [[$finalMC1, $finalMC2]]
 
If _GUICtrlEdit_LineLength($Medical2) = 2 And _GUICtrlEdit_GetModify($Medical2) > 0 Then
    ReDim $MC[UBound($MC) + 1][2]
    $MC[UBound($MC) - 1][0] = $finalMC1
    $MC[UBound($MC) - 1][1] = $finalMC2
    GUICtrlSetState($Medical, $GUI_FOCUS)
    _GUICtrlEdit_SetModify($Medical2, False)
EndIf

 

So basically if $Medical2 = 2 characters the script will resize the array and add the values of $Medical and $Medical1 to it, so far so good.

Next thing I'll be needing is to find out how many items are in the $MC array (found out that Ubound will do the job on this one), I tried using "For...To...Step...Next", then the script threw the following error: "ReDim" used without an array variable.", To be completely honest here I have no idea whats causing that error, this is my 1st time working with Arrays, UBound and ReDim, I got the way for resizing 2D Arrays from a post here on the forums, I tried googling the error and came back with nothing, It's really getting irritating...

  • Solution
Posted (edited)

Palestinian,

You will get more expediant help by posting runnable code.  I've added a gui def and re-aligned some of the variable def's to get something runnable.  If your intent is to add the values read from each edit control to a 2D array then the following does just that.

#include <GuiEdit.au3>
#include <GUIConstantsEx.au3>
#include <array.au3>

#AutoIt3Wrapper_Add_Constants=n

local $gui010       =   guicreate('',400,500)
Local $aSize        =   WinGetClientSize($gui010)
local $Medical  =   guictrlcreateedit('Medical',20,20,100,60)
local $Medical2 =   guictrlcreateedit('Medical2',20,150,100,60)
                                    guisetstate()

local $finalMC1, $finalMC2, $MC[0][2]

while 1
    switch guigetmsg()
        case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    $finalMC1 = GUICtrlRead($Medical)
    $finalMC2 = GUICtrlRead($Medical2)

    If _GUICtrlEdit_LineLength($Medical2) = 2 And _GUICtrlEdit_GetModify($Medical2) > 0 Then
    ReDim $MC[UBound($MC) + 1][2]
    $MC[UBound($MC) - 1][0] = $finalMC1
    $MC[UBound($MC) - 1][1] = $finalMC2
    GUICtrlSetState($Medical, $GUI_FOCUS)
    _GUICtrlEdit_SetModify($Medical2, False)
        _arraydisplay($MC)
    EndIf

wend

If you need help with existing, runnable code, then post it.

kylomas

edit: incidentally, _GuiCtrlEdit_GetModify returns true or false so the coding should look like..

If _GUICtrlEdit_LineLength($Medical2) = 2 And _GUICtrlEdit_GetModify($Medical2) Then
Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted

kylomas, Thank you for the great help, the only existing code I have is what I posted, I can't post a running code because the script runs on a UNHCR website that requires a username and password, and putting together part of my script to make a runnable one doesn't give the exact results as running it in the script itself (no clue why, still looking it up).

Thank you again, I really appreciate it.

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
×
×
  • Create New...