There was a saying in England :: "many a true word is said in jest.".
Anthony Appleyard
Posts
-
There is generally a lot of truth in jokes -
Thanks for a new featureI noticed today when editing a program on Visual C++ 2015 that if I left a variable undeclared, it showed underlined in red, similar to misspellings in Word for Windows. That is useful. Thanks to whoever put that feature in.
-
Finding a directoryThanks for your help to people who ask queries. I know how to ask for a file to read from, or a file to write to :-
BOOL GetFileName(HWND wn,char*file,char*titl,char*filter,short write/*=1*/) {short j;
strcpy(file,title);
ofn.lStructSize=sizeof(OPENFILENAME); ofn.hwndOwner=wn;
ofn.lpstrFilter=filter; ofn.lpstrCustomFilter=0;
ofn.lpstrFile=file; ofn.nMaxFile=1024;
ofn.lpstrFileTitle=title; ofn.nMaxFileTitle=1024;
ofn.lpstrInitialDir=0; ofn.lpstrTitle=titl;
ofn.Flags=write?OFN_OVERWRITEPROMPT:OFN_FILEMUSTEXIST;
j=(write?GetSaveFileName(&ofn):GetOpenFileName(&ofn))?1:0;
return j;}('ofn' and 'title' are declared globally.) but when I need to ask for a directory / folder, I must do something like this:
K=GetFileName(wn, slidefilename, "name of a file in the directory to read slides from?", slidefiletype, 0);
Is there something like GetOpenFileName, but returning the name of a directory rather than the name of a file?
-
Difficulty with Visual StudioI found that I had an array of characters char[1024][256]. I have now changed it to char[256][256], and the bug seems to have gone away. Thanks. I am very sorry to take up your time. When I am developing a program, once in a while I make a backup copy of its source form files.
-
Difficulty with Visual StudioWhen I try to edit my message, the program text displays complete. But in the screen display it is always truncated.
-
Difficulty with Visual StudioThis is what the debugger outputs. The fault is presumably during a proc called _chkstk . I was not hacking or intruding into anything secret.
-
Difficulty with Visual StudioThis is the source form of the failing section of the program: The fail happens at a breakpoint at the start of the line that starts "Main=newwindow". ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{WCHAR**arg=CommandLineToArgvW(GetCommandLineW(),&nargs);
if(nargs<2) argument[0]=0;
else {int i,j=wcslen(arg[1]); for(i=0;iThe indentation has gone, sorry, because I had to send it as plain text.
-
Difficulty with Visual StudioI am trying breakpoints like you suggest. It faults at ######## in this fault printout:- _chkstk proc _alloca_probe = _chkstk push ecx ; Calculate new TOS. lea ecx, [esp] + 8 - 4 ; TOS before entering function + size for ret value sub ecx, eax ; new TOS ; Handle allocation size that results in wraparound. ; Wraparound will result in StackOverflow exception. sbb eax, eax ; 0 if CF==0, ~0 if CF==1 not eax ; ~0 if TOS did not wrapped around, 0 otherwise and ecx, eax ; set to 0 if wraparound mov eax, esp ; current TOS and eax, not ( _PAGESIZE_ - 1) ; Round down to current page boundary cs10: cmp ecx, eax ; Is new TOS bnd jb short cs20 ; in probed page? mov eax, ecx ; yes. pop ecx xchg esp, eax ; update esp mov eax, dword ptr [eax] ; get return address mov dword ptr [esp], eax ; and put it at new TOS bnd ret ; Find next lower page and probe cs20: sub eax, _PAGESIZE_ ; decrease by PAGESIZE test dword ptr [eax],eax ; probe page. ################################### jmp short cs10 _chkstk endp end
-
Difficulty with Visual StudioI have been compiling and running C and C++ programs for very many years: first DJGPP for DOS; then Borland C; then Visual C. Until today, Visual C++ 2017 has given me reliable service. My programs have been settled in their final forms for use and I have not needed to recompile them for over a year. Today, on one of my projects (a graphics handling program), for the first time for over a year, I ventured to try to put a new facility into it. I went into my copy of Microsoft Visual C++ 2017, which at the time was set to Debug mode rather than to Release mode. I recompiled the altered program. It compiled and said that there were no programming errors. But attempt to run the compiled program (which is on my computer in C:\2d\ppp\Debug\ppp.exe ) resulted in a hesitation followed by an exit without displaying some text that it should have made. Meanwhile, the Release version, which is in C:\2d\ppp\Release\ppp.exe , which I had wisely and thankfully left alone and I did not recompile it, still runs as it should and as it has run faithfully for many years. Attempt to run the debugging option (as from the word "Debug" in the top long menu) crashes out with an exception on the instruction "test dword ptr [eax],eax ; probe page.". I tried to run Visual 2019, but its menu display is so different from what I know in Visual 2017 that I could not make head or tail of it. This means that my C++ programs are now stuck as they are and I cannot change them any more. Please how can I get my Visual C++ 2017 to run as it has run reliably for very many years? It was quite enough and adequate for me. What is happening?
-
Iterating over an indefinitely large number of concentric loopsBefore I retired, I had to write, or service, programs that simulated behavior of polymer molecules. Each link in the polymer molecule chain could assume up to 3 possible rotation values. Later I wrote this program to do that sort of job:-
#define N 4
int main()
{int i, j, ncases, x[N], start[N], stop[N], n = N; ncases = 0;
for (i = 0; i 0; x[i] = start[i]) for (i--; (++x[i]) <= stop[i]; i = n - 1) { // iterate over all cases
ncases++;
for (j = 0; j < n; j++) putchar('0' + x[j]); // replace by something useful to be done over every allowed combination of values of x[0:N-1]
putchar(' '); }
printf("\n%d cases found\n~~~~~~~~~~~~~~\n", ncases);
printf("press a key to continue:"); i = getchar();
return 0;
}This seems to do the same as:-
for( i[N-1] = start[N-1]; i[N-1] <= stop[N-1]; i[N-1]++ )
for( i[N-2] = start[N-2]; i[N-2] <= stop[N-2]; i[N-2]++ )
for( i[N-3] = start[N-3]; i[N-3] <= stop[N-3]; i[N-3]++ )
for( i[N-4] = ...............................
etc to ..
for( i[1] = start[1]; i[1] <= stop[1]; i[1]++ )
for( i[0] = start[0]; i[0] <= stop[0]; i[0]++ )
{ work to be done for every allowed combination of values of i[0:N-1] }In case this piece of program text is any use to you.
-
How to get Visual C++ (2015 version) to work in "char = 8 bits" mode?Sorry. I started computer programming in the late 1960's, when computer storage was much smaller (80,000 words memory was big), under early compilers such as Atlas Autocode and Basic, and I got accustomed to one-letter and two-letter variable names. Thanks for your help.
-
How to get Visual C++ (2015 version) to work in "char = 8 bits" mode?Thanks. It compiled OK. What should this become? int discanf(HWND db, int c, char*fmt, ...) { char C[256]; GetDlgItemText(db, c, C, 256); C[255] = 0; return vsscanf(C, fmt, (&fmt) + 1); }
-
How to get Visual C++ (2015 version) to work in "char = 8 bits" mode?I am trying to revive a program that I wrote in years 2001 to 2005 for my old Borland C++ 4.51 compiler. The library functions that its compiled programs called, always ran in the mode of a character = 8 bits, not 16 bits. As this program largely handles text, not numerical values, it will have to compile to run with char = 8 bytes everywhere. For example, in this section: int rundialogbox(HWND wn, HINSTANCE I, char*name, BOOL CALLBACK /*_export*/ proc(HWND db, UINT M, WPARAM S, LPARAM L)) { DLGPROC dp = MakeProcInstance((DLGPROC)proc, I); int i = DialogBox(I, name, wn, dp); FreeProcInstance(dp); return i;} I had type mismatch error of the type char* :: WCHAR*, until in menu Project / Properties I set the character mode from Unicode to Not Set; then this section compiled OK. Whereupon, the next section void diprintf(HWND db,int c,char*fmt,...){ char C[256]; vsprintf(C,fmt,(&fmt)+1); SetDlgItemText(db,c,C); }; failed with this error: 1>faces.cpp(80): error C2664: 'int vsprintf(char *const ,const char *const ,va_list)': cannot convert argument 3 from 'char **' to 'va_list' 1> faces.cpp(80): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast I replaced `char C[256];` by `WCHAR C[256];`, and compilation error still happened. Does my Visual C++ still have an 8-bit-char-mode set of library functions? If so, how to call them?
-
The new upgrade systemThanks. Do you want me to send to you a copy of the old form of my 'dragclip' program?, so that you can investigate why "One-way upgrade. Visual Studio ..." repeatedly asked to upgrade it?
-
The new upgrade systemThanks for your help. I am sorry if I have caused any problems. I tried uploading VS 2017; it installed itself alongside my VS 2015 and did not obliterate it. I used my desktop "Visual C 2015 devenv.exe" icon to access my VS 2015, and I tried to access several of my projects. All but one of them that I tried came up and recompiled successfully, and there was no "One-way upgrade. Visual Studio ..." nuisance. The only project that caused trouble was dragclip_vc, which kept on showing the "One-way upgrade. Visual Studio will automatically make functional changes to the following projects in order to open them. ...". MessageBox. So I remade this project as a new VS 2015 project dragclip2 using copies of dragclip_vc's source files, and this new project behaves OK. I suspect that the "One-way upgrade. Visual Studio ..." nuisance persisted because dragclip is such a small project that it does not have some feature that "One-way upgrade. Visual Studio ..." looks for to see if it has already been called on that project. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Next step for me, I suppose, is to find how to run VS 2017. It looks very different from VS 2015. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I keep pointers to all my Visual C++ projects in a folder called C:\Visual_C\Visual_C_pointers\
-
The new upgrade systemI have now upgraded to VS 2017. I have used it to remake my project 'dragclip_vc'. In it, the top menu has entries for "File, Edit, View, Project, Team, Tools, Windows, Help", but none of then seem to lead to an option letting me compile or run the source file. What should I do?
-
The new upgrade systemWhen I run my project makeobj_vc , the initial black panel shows "Visual Studio / Community 2015". When I opened its help just now, a top panel said "We recommend using Visual Studio 2017 / Download now"; but will that cause a quick replacement of my VS 2015 by VS 2017, or will there be a long complicated process?
-
The new upgrade systemI am using VS 2015. When I opened its help just now, a top panel recommended using VS 2017; will that cause a quick replacement of my VS 2015 by VS 2017, or will there be a long complicated process?
-
The new upgrade systemVictor Nijegorodov wrote:
What VS version are you using? In what version is it about to upgrade?
When I run my project makeobj_vc , the initial black panel shows "Visual Studio / Community 2015". When I opened its help just now, a top panel said "We recommend using Visual Studio 2017 / Download now"; but will that cause a quick replacement of my VS 2015 by VS 2017, or will there be a long complicated process?
-
The new upgrade systemI have VS 2015. Its help recommends upgrading to VS 2017.