|
Been there, done that, found a different job.
|
|
|
|
|
Sounds like there is a big goodies bag at the end if you fix this!
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
If only. I quoted my (very cheap) hourly rate and the customer was obviously taken aback... "But I've been so used to paying £40/hour for years..." I used to charge clients £40/hour... in 1996.
Peanuts and monkeys come to mind
Trouble is I like a challenge, am semi-retired so this is really like a paid hobby, and his offices are fabulous (an old English stately home, complete with wood panelling and huge portraits on the wall) so site visits are interesting! He has now agreed a rewrite is in order (once the initial fire fighting is over) so there's a good few months' work in it.
|
|
|
|
|
As long as it doesn't happen to you... Dilbert Comic Strip on 2013-02-24 | Dilbert by Scott Adams[^]
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
I envy you not.
David A. Gray
Delivering Solutions for the Ages, One Problem at a Time
Interpreting the Fundamental Principle of Tabular Reporting
|
|
|
|
|
Poking around, MS doesn't want you to use GetSaveFileName anymore. Instead, they want you to use the 'Common Item Dialog'. So click on that page, and find a function with 11 indentation levels! Copy and paste it, to find that it is part of a sample code, and relies on other functions in that sample. Try to download the sample, and the page isn't found. But you can download an SDK which supposedly contains the sample? Try to run it, though, and you will get a 'Some components cannot be installed' error, and no indication that the samples are included in it. Oh MS, you funny!
All this because I was trying to figure out a way to allow the user to save program configuration files in the user app work directory, and regular files wherever they wish, but MS, in their infinite non-wisdom, won't allow the directory to be changed using GetSaveFileName , because they believe you will only ever be dealing with one type of file for your application.
(Of course, they have the same issue in MS Word, and other Office programs, because they store config files like macros in a special subdirectory until the user changes where they store them. Afterwards, the dialog will default to that special directory until after you change it once. At least that was the case the last time I played with macros in Word.) Double-
|
|
|
|
|
This is why I use .NET
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
In .NET, can you create a program where the save file dialog will default to the user's AppData folder for files like .ini files, and then back to the user's regular folders for their regular files? (I doubt you can, because I think this is a limitation of MS believing they know better than us how programs should work, and overriding their dialogs to disable such use.) If I'm wrong, I'm not going to rewrite, but would be interested to know.
|
|
|
|
|
|
Interesting. Thanks for the knowledge!
|
|
|
|
|
That's correct, you can not save app.config settings in the application directory with C#.
I have a simple fix which allows this using file based search and replace, if you want I can send you some code, just let me know
|
|
|
|
|
Please do, and I'll see if I can pound it into C++.
|
|
|
|
|
I will post it tomorrow, as I don't have the source code at home
|
|
|
|
|
Cool!
|
|
|
|
|
Here's my code, as you can see it's quite simple:
this.SaveSettings(Application.ExecutablePath + ".config");
private void SaveSettings(string fileName)
{
string oldHostname = Properties.Settings.Default.HostnameUrl;
string oldSipClients = Properties.Settings.Default.SipClients;
string oldVersion = Properties.Settings.Default.LastExeVersion;
if (this.textBoxHostname.Text != oldHostname)
{
this.ConfigFileUpdate(fileName, "HostnameUrl", oldHostname, this.textBoxHostname.Text);
}
if (this.textBoxSipClients.Text != oldSipClients)
{
this.ConfigFileUpdate(fileName, "SipClients", oldSipClients, this.textBoxSipClients.Text);
}
if (string.Compare(this.newExeVersion, oldVersion) > 0)
{
this.ConfigFileUpdate(fileName, "LastExeVersion", oldVersion, this.newExeVersion);
}
}
private void ConfigFileUpdate(string fileName, string keyName, string searchstring, string replacestring)
{
try
{
if (string.IsNullOrEmpty(searchstring) || string.IsNullOrEmpty(replacestring))
{
return;
}
searchstring = ">" + searchstring + "<";
replacestring = ">" + replacestring + "<";
string[] configLines = File.ReadAllLines(fileName);
for (int i = 10; i < configLines.Length; i++)
{
string linePrevious = configLines[i - 1];
string line = configLines[i];
if (linePrevious.Contains(keyName) && line.Contains(searchstring))
{
configLines[i] = line.Replace(searchstring, replacestring);
break;
}
}
File.WriteAllLines(fileName, configLines);
}
catch (Exception ex)
{
Debug.Print(ex.Message);
}
}
|
|
|
|
|
|
Save it in other place and then move the "closed" file there
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
All well and good, until you want to load one of those files!
|
|
|
|
|
Here is another page with more then 20 Sample code links that do not work:
Shell SDK Samples (Windows)
-> you have to click (for example):Automatic Jump List Sample -> Downloading the Sample
-> You'll either end up with page not found or just the SDK Link
I don't think its funny and certainly not helpful
|
|
|
|
|
David O'Neil wrote: and find a function with 11 indentation levels! One more reason to change to .Net. Where do these many circles of hell levels of indentation come from?
The lack of a proper exception implementation in old-style C/C++.
Just look:
HResult hr;
hr = ;
if (SUCCEEDED(hr))
{
hr = ;
And in case of error, ... it does nothing. Just the user wonders why it does not work, the service hotline people will be delighted by not having any indication of why things do not work.
C# would prefer to throw an exception in case of failure, and no need to handle each place of potential failure separately. Of course, catching the exception and - more importantly - handling it usefully, are still things the developer has to take care of (but it's rather easy).
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
something = Anotherthing - ((condition == 0) ? (assignment_here = object->method()) : someothervalue);
So we have: an arithmetic expression of which one operand is actually the result of the ternary operator, which in turn assigns a value to another unrelated variable and calls a function... but only if the condition of the ternary operator is true.
This thing is pure evil and is sapping away at my sanityk lanòsak òjslshf pAHRW R'LYEH.
GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
It needs some shift lefts and shift rights thrown in for good measure. It's not obscure enough.
This space for rent
|
|
|
|
|
I would only make a couple of changes
something = Anotherthing - (condition ? someothervalue : (assignment_here = object->method()));
I never liked
condition == 0 I like
!condition much better.
|
|
|
|
|
Currently I am so fortunate that my programming is in a language where (numeric != bool)
In my last plain C project, I happened to set up a "#define ever ;;" so that I could write "for (ever) {..." to make an infinite loop, which is not uncommon in embedded code. (In the CHILL language, made for programming phone switches, "DO FOR EVER ..." is defined in the basic language.) One of the other team members reacted quite fiercly to this, searching through the entire code base for "for (ever)", adding a nasty commit message about "someone" who were trying to make funny jokes in the code, and he changed it to the proper "while (1)". The header project files did define "true" and "false" constants, but he woudn't accept even "while (true)": There is one proper way to make an infinte loop in C, and that is "while (1)".
I was seriously considering to change it to "while (2)", with a commit message that 2 makes it twice as clear that the loop should run for (ever), but I decided not to. My relationship to that guy was bad enough without further provocations.
So, provided "condition" is a bool variable, or an numeric variable that stores nothing but the value of bool expressions, I certainly agree that "!condition" is the proper way. But if "condition" is a numeric value treated as such (e.g. a counter from n down to 0), treating it as a bool for flow control is bad. Then "condition == 0" is far better.
Same with pointers. I detest "if (!nextpointer) { /*leave loop*/" - that should be "if (nextpointer == null)" (or "nil" or "empty" or whatever your favorite language calls is).
Which makes me think of that really nice construction I have encountered in a single language: "FOR currentpointer IN listhead:nextpointer DO..." - "nexpointer" being the name of a pointer member in the class "listhead" (and "currentpointer") points to.
|
|
|
|