6 Replies - 664 Views - Last Post: 06 April 2018 - 11:57 AM

#1 bobsmith76   User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 246
  • Joined: 14-February 17

How do code those "don't ask me this again" commands?

Posted 05 April 2018 - 06:32 AM

You know those software apps that ask you a question and you have the option to click a button that says "don't ask me this again". How do you program that stuff in general? Because the only way I can think to do it would be to create a pickle (in python that's what they're called, I don't know about other languages), save that pickle and then each time the program runs it opens that pickle and gets the command to not ask that question again from that pickle.

Is This A Good Question/Topic? 0
  • +

Replies To: How do code those "don't ask me this again" commands?

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14244
  • View blog
  • Posts: 57,144
  • Joined: 12-June 08

Re: How do code those "don't ask me this again" commands?

Posted 05 April 2018 - 06:37 AM

For anyone else: Python Pickle

Yes - that's about right. Save in some sort of roam data file, or a settings file near the execution of the app. When it loads it checks for the file.. if there, read the settings, and act appropriately. If not then ask away.
Was This Post Helpful? 0
  • +
  • -

#3 bobsmith76   User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 246
  • Joined: 14-February 17

Re: How do code those "don't ask me this again" commands?

Posted 05 April 2018 - 06:55 AM

View Postmodi123_1, on 05 April 2018 - 06:37 AM, said:

For anyone else: Python Pickle

Yes - that's about right. Save in some sort of roam data file, or a settings file near the execution of the app. When it loads it checks for the file.. if there, read the settings, and act appropriately. If not then ask away.



cool, thanks a lot.
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: How do code those "don't ask me this again" commands?

Posted 05 April 2018 - 09:23 AM

Assuming you have a enum type for reminders...

public enum CONFIRMATION
{
    EXITWIHTOUTSAVING,
    SENDWITHOUTPROOFREADING,
    INCLUDEGEOLOCATION,
}


I would think you could do a Dictionary<CONFIRMATION, bool> that tracks whether or not to show a dialog for that situation.

Seudo logic
On closeing, if DocumentDirty && Dictionary.GetValue(EXITWITHOUTSAVING) is false - then show dialog first
Was This Post Helpful? 0
  • +
  • -

#5 ndc85430   User is online

  • I think you'll find it's "Dr"
  • member icon

Reputation: 869
  • View blog
  • Posts: 3,495
  • Joined: 13-June 14

Re: How do code those "don't ask me this again" commands?

Posted 05 April 2018 - 09:32 AM

Cookies?
Was This Post Helpful? 0
  • +
  • -

#6 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 11137
  • View blog
  • Posts: 19,089
  • Joined: 19-March 11

Re: How do code those "don't ask me this again" commands?

Posted 05 April 2018 - 12:08 PM

If you're storing data locally, pickles are fine or you could include a mysqlite db which might be easier to read and maintain.
Pickles are interesting, in that they read arbitrary code and execute it, so you could expose yourself to an attack vector if you rely on them. Basically, if someone pickles a class that does something evil and gets it into a distribution of your app then anyone loading your app will have something evil happen. Not sure how likely that is, but it's something to consider.
Was This Post Helpful? 0
  • +
  • -

#7 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6335
  • View blog
  • Posts: 21,747
  • Joined: 05-May 12

Re: How do code those "don't ask me this again" commands?

Posted 06 April 2018 - 11:57 AM

And hence the warning near the top of that linked page stating the dangers of ensuring loading pickles only from trusted sources.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1