Permanent first time set-up

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
ZeitenWanderer
Pro Scripter
Posts: 68
Joined: Wed Dec 07, 2005 7:13 am

Permanent first time set-up

Post by ZeitenWanderer » Thu May 17, 2007 9:02 pm

Hi,

I wonder how to set up a checkbox, which would keep a desired setting - once it was set up. Means: If the user has set the check box, that email should always be deleted on the pop3server (after having downloaded emails), one should not have to use the checkbox again, which would cause a mess, if it is being remembered only occasionally.

Cheers,

George

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

Post by JRL » Thu May 17, 2007 10:33 pm

Use EditIniFile> and ReadIniFile>

Here's an example:

Code: Select all

IfFileExists>%TEMP_DIR%CheckBoxSetting.ini,Continue
  WriteLn>%TEMP_DIR%CheckBoxSetting.ini,wresult,[Setting]
  WriteLn>%TEMP_DIR%CheckBoxSetting.ini,wresult,CheckBox=False
Label>Continue
ReadIniFile>%TEMP_DIR%CheckBoxSetting.ini,Setting,CheckBox,CheckBoxSetting

Dialog>Dialog1
   Caption=Dialog1
   Width=314
   Height=94
   Top=112
   Left=46
   CheckBox=msCheckBox1,Do Something,40,24,97,%CheckBoxSetting%
   Button=Ok,176,24,75,25,3
EndDialog>Dialog1

Show>Dialog1,r1

If>%DIALOG1.MSCHECKBOX1%=False
  EditIniFile>%TEMP_DIR%CheckBoxSetting.ini,Setting,CheckBox,False
Else
  EditIniFile>%TEMP_DIR%CheckBoxSetting.ini,Setting,CheckBox,True
EndIf

MDL>Checkbox = %CheckBoxSetting%

Run it over and over again and you will see that your previous setting is saved and is displayed in the dialog.

ZeitenWanderer
Pro Scripter
Posts: 68
Joined: Wed Dec 07, 2005 7:13 am

Resulting question

Post by ZeitenWanderer » Fri May 18, 2007 6:34 pm

Well, beginner that I am, I tried to decode your example (thank you for it) by reading the help file and erasing and inserting again paragraph by paragraph. :-)

But another question occured to me: Which road should one take, that
- the script could be compiled and distributed plus
- the user won`t be asked any question, which a scripter could avoid?

Means, which path could I safely enter, that the ini-file would neither be erased (as would happen sooner or later in the system temp directory), nor cause a fuzz?

Checking the help I ran into:

Input>path,Please enter directory to create :
CreateDir>path

But this would cause even more code to produce, when it would be much more sufficient to save it in the same directory as where the macro would be. BUT - now imagine how many users would not create a subdirectory, but rather run any file directly from the desktop ... Creating a subdirectory there would not be the best idea. Thus - a minimum installing routine seems to be the best thing to do or would anyone more experienced have a better plan :?:


Cheers,

George

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

Post by JRL » Fri May 18, 2007 7:21 pm

The sample script creates the ini if it does not exist. If you are concerned that the file will be deleted from the temp directory, put the file in any other directory where it will not be deleted. The Windows folder is usually safe from deletion. Or, as you pointed out, you could create you own directory for example, under C:\program files.

I generally do not ask the user where they want items to be placed, if you do that you run into the same problem you're facing now. You have to find a location to store their choices so that your program can use that data next time it's run.

Another possibility would be to not use an ini file but create a registry entry instead. I would recommend this only if you are comfortable dealing with the registry. Look in help under RegistryReadKey> and RegistryWriteKey>.

ZeitenWanderer
Pro Scripter
Posts: 68
Joined: Wed Dec 07, 2005 7:13 am

Works all right, now how to hide it in an extra setup?

Post by ZeitenWanderer » Fri May 18, 2007 8:23 pm

Hm, yes, ok, as a newsbie I better would not mess with someone else`s registry ...
:lol:

Concerning the temp registry, I thought it would be awful, if someone would erase the the content in the temp directory regularly as many programs offer.
Nevertheless, guess, I misinterpreted something here.

Ok, since there will be more set-up options, I would like to hide all of these under a button "Setup".

The full script should later be able to run all by itself, with occasional options that a user could interfere here and there. Otherwise automatic processes could tend to irritate the computer owner a little too much...

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sat May 19, 2007 12:22 am

An alternative to TEMP_DIR would be to use SCRIPT_DIR which is the directory of the running script.

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