• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

Question About "ProgEx37 -- Windows GUI Programming . . ."

Started by Seamus Decker, August 08, 2019, 01:48:36 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Seamus Decker

I have a question about ProgEx37 -- Windows GUI Programming; Basic Template Program With Discussion. Did not see any questions or discussion in that thread, so I wasn't sure if it would be poor etiquette to post a question in that thread.

My question: When Frederick gets to the "tchar1.cpp" example, he states
QuoteIt gives precisely the same output as Ansi.cpp (1st little program above).

But for me, it doesn't. I've typed it in and copy-pasted it twice and I get:
//iLen             = 13
//sizeof(szBuffer) = 28

Not
//iLen             = 13
//sizeof(szBuffer) = 14

I have not yet fully digested that whole post, but this seemed like a non-trivial matter, i.e., "the generic functions and data types" are NOT reducing "simply to the ansi single byte char based functions."

Seamus Decker

Well this is peculiar. The array itself is a 14 byte object, but for some reason the output says it is a 28 byte object. Comprehension of sorcery is behind this is above my pay grade I think, but this at least reconciles the inconsistency enough for me to let it go and carry on.

If anyone has a clarification for what is going on there, I appreciate it.

Paul Squires

Is len reporting the number of characters (13) and sizeof the actual size of the string being unicode so it's two bytes per character (26) plus two bytes for the trailing nul terminating character (28)?.
Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com

James C. Fuller

I emailed Fred and here is his response:


For some reason I can't seem to log in to Jose's Forum.  I seem to recall this happening before.  In any case, I finally found the post up in the main section of Jose's board, and it looks to me like the pre-defined symbol by Microsoft is causing the fellow's program to run as a UNICODE build as opposed to an ansi build, and that's why he is confused.  You are certainly aware of that issue, aren't you?  The issue is that when using Visual Studio  all builds are UNICODE unless one goes into the 'General Properties' window of the project, where one finds a dropdown where one can select ansi, wide character etc.  It defaults to wide character.  Since you and I work from batch files or command line, we don't have to deal with that.  Perhaps if you can log in you might mention that to the fellow?  He's worried about it.

Seamus Decker

#4
Quote from: James C. Fuller on August 09, 2019, 11:49:35 AM
I emailed Fred and here is his response:


For some reason I can't seem to log in to Jose's Forum.  I seem to recall this happening before.  In any case, I finally found the post up in the main section of Jose's board, and it looks to me like the pre-defined symbol by Microsoft is causing the fellow's program to run as a UNICODE build as opposed to an ansi build, and that's why he is confused.  You are certainly aware of that issue, aren't you?  The issue is that when using Visual Studio  all builds are UNICODE unless one goes into the 'General Properties' window of the project, where one finds a dropdown where one can select ansi, wide character etc.  It defaults to wide character.  Since you and I work from batch files or command line, we don't have to deal with that.  Perhaps if you can log in you might mention that to the fellow?  He's worried about it.

That makes sense. I will examine it and I imagine it will fix it.

Thanks so much for the help, and also to Frederick Harris: huge thanks! for that tutorial "ProgEx37" tutorial 'series.' Slowly making progress in that, and it is exactly what I needed to move forward as a developer!

Based on the ~35k views of the thread, I am not alone!  :)

ADDIT: Whoo hoo! FIXED!  ;D
iLen = 13;
sizeof(szBuffer) = 14

In my experience, not knowing how to control the IDE "starship" is a big part of the problem, so I always prefer to walk through these complications and sort them out. I appreciate the help!

Frederick J. Harris

Quote
In my experience, not knowing how to control the IDE "starship" is a big part of the problem, so I always prefer to walk through these complications and sort them out. I appreciate the help!

For a long time starting back in the 1980s IDEs were a big help.  But they just kept adding features and becoming more and more complicated.  Visual Studio is the classic example of this.   I believe things have reached the point where they are now an impediment to someone just starting out at programming.  I'm not saying they aren't useful, its just that for folks that started out programming a long time ago and 'grew up' with them, they are more understandable.  Take your situation with character sets.  The particular setting that caused your program to default to wide character builds is fairly well hidden.