need help: save/load dialog edit to .ini and identifing text

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
JeffDaruecan
Newbie
Posts: 18
Joined: Thu Mar 25, 2010 11:00 am
Location: Vancouver

need help: save/load dialog edit to .ini and identifing text

Post by JeffDaruecan » Thu Mar 25, 2010 12:32 pm

Well I have finally run into a snag with creating some scripts. Up until now most things I have created I've been able to search and read the blogs/other support inquiries but now I'm stuck and figured might as well make an account it was bound to happen sometime ;)

Okay, here is what where I'm stuck. I need a dialog with has an Edit box to type no less than 6 and no more than 20 digits in that has a save to an ini file which automatically load up when the dialog is opened. ini location is %Script_Dir%

from here there will be a Run button near the save button or somewhere on the same dialog window. when the Run button is pressed It needs to analyze the text digit by digit left to right and do a task depending on what letter/number/symbol is typed in and if it is upper case or lower case.

such as if the edit box had "National" written in it, it would see the upper case "N" then type a small pre-determined phrase or have it do a findimagepos command, then see the lower case "a" and do something else and so on. *I don't need help creating what each digit does*


Right now I have all the numbers/letters/symbols set up for the tasks that they will perform. I just don't know where to begin with having it load/save data from the edit box in a dialog and then analyze each digit one by one.

I'm not asking for someone to write the whole chunk of the script I need (although that would be nice and save me time hehe) I'm mainly looking for someone to point me in the right direction as I don't even know if having it set to save/load to/from an ini file is the best way to go.


If something is not clear just ask, while writing this I found it hard to explain what I'm wanting it to do exactly which I think is part of the problem that I can't find a solution.


Thanks,
Jeff Daruecan

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Mar 25, 2010 9:39 pm

I'm not following what you want to do with the ini file. But here's a chunk of code to get you pointed in a direction for the rest of it.

Code: Select all

Dialog>Dialog1
   Caption=Dialog1
   Width=265
   Height=174
   Top=213
   Left=443
   Button=Run,87,97,75,25,3
   Edit=msEdit1,33,38,192,
EndDialog>Dialog1

Show>dialog1

Label>Loop
  GetDialogAction>Dialog1,res1
  If>res1=2
    Exit>0
  EndIf
  If>res1=3
    GoSub>Evaluate
  EndIf
  Wait>0.01
Goto>Loop

SRT>Evaluate
  Length>Dialog1.msEdit1,len
  If>{(%len%<6)or(%len%>20)}
    MDL>Improper number of characters, length must be between 6 and 20.
    GoTo>Restart
  EndIf
  Let>kk=0
  Repeat>kk
    Add>kk,1
    Midstr>Dialog1.msEdit1,%kk%,1,char
    GoSub>ProcessChar
  Until>kk,%len%
  Label>Restart
  ResetDialogAction>Dialog1
END>Evaluate

SRT>ProcessChar
  MDL>The %kk% character is "%char%"
END>ProcessChar

JeffDaruecan
Newbie
Posts: 18
Joined: Thu Mar 25, 2010 11:00 am
Location: Vancouver

Post by JeffDaruecan » Thu Mar 25, 2010 11:13 pm

Thank you, the SRT>Evaluate should work perfectly with a couple minor changes :D



~EDIT~

Thanks again just had some time playing around with the script you gave me and I got it working to fit exactly what I needed :)

There is only one part I cant figure right now..

how do I get the text entered into the edit box to update to an INI file?
The editbox is set to read
ReadIniFile>%Script_Dir%\PIC.INI,Settings,PIC,P_IC
in the dialog I have
Edit=msEdit1,33,38,192,P_IC

which contains a basic default message of "Enter Message Here." Everything is working perfectly. except after the new text is entered how do I get it to change the value and overwrite the default message in the Ini file?

So far I placed made a subroutine just before your script goes to the evaluate subroutine called Update INI it looks like this

SRT>Update INI
EditIniFile>%Script_Dir%\PIC.INI,Settings,PIC, *what do I put here to get it to get data from the edit box*
END>Update INI

JeffDaruecan
Newbie
Posts: 18
Joined: Thu Mar 25, 2010 11:00 am
Location: Vancouver

Post by JeffDaruecan » Thu Apr 01, 2010 11:33 am

Figured I'd answer my own question real quick so not to let a thread die without a definite answer. also helps for future people with same problem/questions using the search. :)

To have a .INI file value updated by text entered into an edit box just place this code before the end of your script

This will update an INI file with whatever has been entered into msEdit1 from Dialog1
EditIniFile>%Script_Dir%\Sample.INI,Settings,Value,Dialog1.msEdit1

Explained:
EditIniFile>INI File, Section Name, Entry Name, New Value

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts