March 28, 2024, 04:48:43 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


A few questions and suggestions

Started by Mike Stefanik, July 05, 2008, 02:57:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mike Stefanik

July 05, 2008, 02:57:24 AM Last Edit: July 05, 2008, 03:19:14 AM by Mike Stefanik
I'm not sure if there's any plans for further development with CBasic, but I spent some time working with it just for fun, and ran into a couple of issues.

1. Creating an executable under Vista doesn't work unless you run CBasic with administrative privileges, regardless of where you say you want to create the file. Also, the default of "c:\filename.exe" is generally a bad idea. Defaulting to the current working directory, or somewhere in the user's documents folder would be better, I think.

2. If you browse for a file using the IDE, it changes the current working directory which affects the programs that you run after that. I think that ideally, the current working directory should be set to where the .CBA file is, and it should be preserved whenever open/save file dialogs are shown.

3. DLLs aren't unloaded across executions of a program from within the IDE. I guess a case could be argued both ways as to whether or not this is a good thing, but I was surprised to see that when the program terminated, the DLL wasn't unloaded.

4. I'm not sure if this supported or not, but passing the address of a declared function (using &) similarly to how you would in EBasic causes CBasic to crash (looks like its trying to dereference a NULL pointer internally). If this isn't supported, it's an unfortunate limitation because it means that you can't use API functions that expect the address of callback functions.

5. Function declarations for a DLL can't seem to have more than 12 arguments or it complains about a syntax error.

And a few suggestions:

1. Allow the use of "then" in a multi-statement if block. In other words, code like this causes CBasic to throw a fit about syntax errors:


Def A As Int

A = 1

If A = 1 Then
    Print "The value of A is 1"
Else
    Print "The value of A is not 1"
EndIf


The interpreter complained that there was a syntax error on the "If A = 1" line, and after starting at that for a while and thinking that something was seriously borked, I realized that it didn't like the "Then" because that's used with single line if statements. The first problem is that just saying "syntax error" really isn't useful information in that context; it's telling you it doesn't like something, but it's not telling you what it doesn't like. But in any case, I'd suggest making that legal syntax simply because it's what's used by 99% of the BASIC languages out there and will save folks from pulling their hair out.

2. Allow line continuation using "_"; even though it's interpreted, the code isn't being typed in by hand on a console (and even then, there could be line continuation just as there is with the shell on UNIX systems) and the ability to split lines can make code a lot easier to read in some cases. Was there a specific reason this was omitted, or just an oversight?

3. Have the dialog editor generate more than just the control statements, or at least give it the option to generate code that actually implements the dialog message handler. I think it would make things a lot easier for new programmers or ones that aren't familiar with the SDK style of dealing with messages (e.g.: Visual Basic programmers); providing the basic framework with comments saying "this goes here" would go a long way in getting them pointed in the right direction.

4. Have the dialog editor use constants, not numeric values, for style flags. Using @WS_VISIBLE rather than some string of hex values will not only make it easier to understand, it'll make it easier to modify without having to go back into the dialog editor, change one option, regenerate the code, etc.

5. With how components are created and used, I'd suggest adding a statement like "Import" or "Use" which calls the subroutine that's created inside the component to initialize it. It would make it clear, from a source perspective, that it's different than just a regular subroutine. In other words, if you had a component that declared some functions in a DLL and the subroutine was named MyFunctions, then:


Import MyFunctions


Would seem to be clearer as to what's going on (oh, a component is being used) rather than:


Gosub MyFunctions


And when looking through the code, you can't find a subroutine named "MyFunctions". You perhaps could also then extend the statement to allow a component file to be specified without having to explicitly add it:


Import MyFunctions From "mystuff.cbo"


That would make one less file that you have to worry about, eliminating the need for the ".cbl" file that has to shadow the source file. Anyway, just a few thoughts there.
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

GWS

Wow .. that's an unexpected and appreciated analysis Mike ..  :)
It will take a bit of assimilating.  I'm so surprised you've devoted some of your valuable time to looking little CBasic over .. many thanks.

Remember. CBasic simply resurrected the languishing IBasic from an unfairly early grave - and IBasic itself was in computing terms, a geriatric  :) piece of 8 year old software.  Pretty well the first of Paul's amazing contributions to Windows programming tools.

QuoteI spent some time working with it just for fun

That's the spirit - did you like it? .. I know it's a bit primitive compared with the technical stuff you do ..  ;D

QuoteI'm not sure if there's any plans for further development with CBasic

Can't say just yet - it's down to the boss .. and time ..  ;D :D  :-X

best wishes, :)

Graham





Tomorrow may be too late ..

aurelCB

What you talking about?
I think that is more logical:
---------------------------------------------
If A = 1
    Print "The value of A is 1"
Else
    Print "The value of A is not 1"
EndIf
----------------------------------------------
then :
---------------------------------------------
If A = 1 Then
    Print "The value of A is 1"
Else
    Print "The value of A is not 1"
EndIf
--------------------------------------------
If you dont like CBasic it is your problem :)

GWS

I can reply to a couple of your comments so far ..  :)

1.  Creating the executable in c:\prog.exe

You know, I'd never noticed that default. (Originally it was c:\temp\prog.exe)
 
I always set up my applications in their own working directory with all associated files grouped together there.  This can be anywhere on the disk, such as f:\cbapp1 .. and the .exe would be placed there by navigating from the c:\ compile default to my application directory.

So yes it would save having to navigate if the compile dialog came up with the working directory in the first place ..  :)

What the dreaded Vista does I've no idea, since I've chucked it off my computer and gone back to XP ..  ::)


2. Allow the use of "then" in a multi-statement if block

It would seem clearer if the logic was:

IF (statement is True) THEN

  .. do this

ELSE

  .. do this

ENDIF

It's not done that way universally though..  Blitz Basic, DarkBasic and PureBasic leave the 'THEN' out of the first line of a multi-line 'IF'
Visual Basic has it in, as does Liberty Basic ..

You get used to not having it in - I take your point about being as consistent as possible though ..

More thinking needed about other points .. phew you don't expect a major query at weekend ..  ;D

all the best, :)

Graham



Tomorrow may be too late ..

GWS

Aurel .. be nice .. :)

You may not have seen a development discussion on this forum - it was quite common years ago.

It's all done in a friendly fashion .. one person makes an observation - others make their comments - and Paul considers if there's anything there that will improve the system (and whether it's feasible of course  ;))

You never know if some really good idea will surface.  So all contributions gratefully received ..

best wishes, :)

Graham
Tomorrow may be too late ..

Mike Stefanik

Quote from: aurelCB on July 05, 2008, 10:59:59 AM
If you dont like CBasic it is your problem :)

It's not about liking or disliking the language. I was offering some observations, mostly as feedback to Paul, about some features of the language and suggestions where it could be improved, as well as a few problems that I found. Personally I don't really see the advantage in using it over EBasic, but that's why there's different flavors of ice cream. Strawberry Swirl isn't for every everyone.

As to the If..Then..Else construct, it's predominantly used by the most popular dialects of BASIC that exist out there. My comment was twofold, really. Supporting the use of "Then" in a multi-statement conditional would be nice; but if not, at least have the language emit an error message that's more specific than "syntax error". For example: "Syntax error, unexpected THEN at line xxxx"

Graham, as far as Vista is concerned, there's a few compatiblity issues there. You don't want to create executables off the root directory or in protected system folders like C:\Program Files. Paul updated Aurora and EBasic to use the document folder for projects and examples, he just needs to do the same thing with CBasic.

Also, when you create components, it tries to create them in the Components folder under where CBasic is installed. The problem is that the default is under C:\Program Files (which is a protected folder), so the virtualization code in Vista ends up redirecting the file so that it's actually created in "C:\Users\<User>\AppData\Local\VirtualStore\Program Files\Ionic Wind\Creative BASIC\components". The problem is that a more inexperienced developer (or one that's just not familiar with how the virtual store works in Vista) would see the message from CBasic that the component was created, but they would look in "C:\Program Files\Ionic Wind\Creative BASIC" and wouldn't even find the components folder. Ideally, Paul would set things up so that it would all be done in the documents folder, so you could have "C:\Users\<User>\Documents\Creative BASIC" as the root, with subfolders named "Projects', "Samples" and "Components".
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

aurelCB

Why you prefer this documents stuff ,virtual also ???

Mike Stefanik

It's not a matter of preferring it, it's how security in Windows Vista works. You can't create files under C:\Program Files unless you run with elevated privileges.
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

GWS

July 05, 2008, 02:13:18 PM #8 Last Edit: July 05, 2008, 02:17:40 PM by GWS
Mike, that's where I've grown apart from Windows - what you describe seems horrendous to me.

I have my hard disk partitioned into 7 logical drives - I use each for particular types of work, so I know where to look for games, EBasic work, .. whatever.

The C: drive is where Windows lives and all it's heap of associated software.   I have a 'documents and setings' folder of course .. but I keep almost nothing in there.   Reason:  I clear my machine down regularly and C: gets wiped prior to re-installing Windows.  All other partitions which hold my files and programs stay the same.

So I want to decide where I put my applications and source code/data - it would never be on the C: drive.

I always install EBasic to the E: drive, CBasic to the F: drive - along with any applications I'm working on.

I don't mind an application offering a default on C: - but I would want to over-ride it.  I will not be dictated to by Microsoft.

Vista it seems has put the cat among the pigeons - and I want none of it.  A personal computer is just that - I decide what happens (including wiping the whole lot) - not a dictatorial operating system.

I can see what you're saying though - thanks for the insight - but it doesn't suit my way of working.  There seems to be no logic in it.
It seems to me to be better to put each application in it's own folder - wherever I want on the hard disk.

I've just loaded a game to my G: drive together with it's .exe and all associated files.  It will execute from there - what's wrong with that .. ::)    If it doesn't fit with Vista vision - who cares ..  :P

all the best, :)

Graham
Tomorrow may be too late ..

Mike Stefanik

Actually, other drives aren't an issue. Vista wouldn't care if you're putting files in G:\FolderName because it's not considered a secure part of the operating system. C:\Windows and C:\Program Files are off-limits though, unless you're running with elevated privileges. That's why installers prompt for permission; they need to run as the administrator in order to install the files, modify the registry and so on.

The thing is, XP supports exactly this same kind of thing (and actually makes it a bit more arduous), but the difference is how the operating system works by default. With XP, the "security switches" in the operating system are effectively turned off and applications (a) usually run in the context of a user that has administrative rights; and (b) expect that they have unrestricted access to the operating system and filesystem. Vista just turned those "switches" to the on position by default, actually enforcing the security model that's largely existed since Windows NT was released. Just so you're aware, it is possible to disable all this and tell Vista to work pretty much the same way that XP did security-wise. It's just for application developers, you can't assume that users are going to have UAC disabled, so you need to write your software more "defensively" these days. And this isn't going away; Windows 7 will be building on the same security model that's in Vista. I realize that it's something that you don't like (and you're not alone); I'm not making judgements here, just providing information.

As to the issue of where files are stored, putting everything in a centralized location under the user's "home" folder actually makes a lot of sense when you think about the corporate enterprise. There, you don't want users just creating files everywhere. Having everything in one place makes it a lot easier for site administrators to backup files, and know that they're getting all of the user's documents, settings and so on. They don't want to backup C:\Program Files because (a) in most cases you have to reinstall anyway and (b) on a large corporate network, you'd be backing up duplicates of tremendous amounts of data. If you have 300 employees, you don't want to backup 300 copies of Microsoft Office and whatever else is installed C:\Program Files. You just care about their data and settings, and that's all under C:\Users\<UserName> (on Vista). So backing up that folder catches pretty much everything.

Back in the good ol' days, I had things setup similarly to how you do with multiple partitions, different drive letters assigned for different things and so on. Now, everything is arranged in project folders and it just gets dumped nightly to an external 1T backup disk with a 7-day rotation.
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

aurelCB

Yes i agree with Graham who cares for Vista ;)

Mike Stefanik

Quote from: aurelCB on July 05, 2008, 02:32:28 PM
Yes i agree with Graham who cares for Vista ;)

Not a good position to take, given that it's the default operating system that's installed on every new computer, and Microsoft is no longer selling retail copies of XP. You may not care about it, but there's a lot of folks who do use it. In any case, it's ultimately up to Paul if he decides that it's worth investing more time in.
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

aurelCB

OK,Ok i only know that my  small interpreter work on Vista , that is enough for me
bye....

LarryMc

Quote from: aurelCB on July 05, 2008, 03:02:17 PM
OK,Ok i only know that my  small interpreter work on Vista , that is enough for me
bye....
But does it work in every case on Vista.
How many people have told you that it works on Vista?
How many of those told you they had UAC enabled?
How many of those told you they had UAC disabled?

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Ionic Wind Support Team

Larry,
The programs created will work on Vista, guaranteed.  Mikes comments were about the compiler itself, which is something I am addressing.  The defaults for CBasic are just that, defaults, and it was a simple matter to change them in the latest version I am working on.

Paul.
Ionic Wind Support Team

LarryMc

Paul

Thanks for straightening my scrambled brains out.

I get bogged down in all that mumbo-jumbo.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Duffer

aurelCB:  You are right "then" is long dead when it comes to syntax for BASIC variants.

You can put the other comments up to that fact that Mikes parents must have his Vista account limited, hence the restrictions he is running in to.  Most adults and all developers using Vista will have UAC turned off.

We had this same conversation back on the old forums when Vista was first released.  Programs compiled with Creative BASIC work fine with Vista and work fine with the DEP (hardware & software) protection in XP SP2 and above.


aurelCB

What you mean"Most adults", i'm not a kid i have 39 ?

GWS

QuoteC:\Windows and C:\Program Files are off-limits though

Oh, I can go with that ..  :), and I'm happy to hear using other drives than C: is no problem.

Thanks for your broad view Mike .. I'm glad I'm not in Industry any more, it must be pretty tricky to work in modern conditions and security.  ::)

Still, as long as programs we write run with no problems for users, that's fine.

all the best, :)

Graham
Tomorrow may be too late ..

Duffer

Quote from: aurelCB on July 06, 2008, 12:54:05 AM
What you mean"Most adults", i'm not a kid i have 39 ?
Something was lost in translation.  I was merely pointing out do not pay too much attention to the comments made by Mike as they will not apply to the majority of Vista users.

GWS

Getting back on thread:

3.  Allow line continuation using "_"

I don't mind that if it's possible to implement easily. 

It's never bothered me though, 'cos if a line gets a bit too long, it's usually possible to insert one or more auxiliary statements to clarify things.

So if you have:

IF (thisvariable - 2 * (anothervariable - SQRT(athirdvariable)) > sometestvalue) THEN resultvar = thisvariable + 3 * sometestvalue

can become:

aux1 = thisvariable - 2 * (anothervariable - SQRT(athirdvariable)
aux2 = thisvariable + 3 * sometestvalue
IF (aux1 > sometestvalue) THEN resultvar = aux2

This method is probably easier to follow and makes debugging easier.

all the best, :)

Graham
Tomorrow may be too late ..

pistol350

Quote from: GWS on July 06, 2008, 01:29:11 AM
Getting back on thread:

3.  Allow line continuation using "_"

I don't mind that if it's possible to implement easily. 

It's never bothered me though, 'cos if a line gets a bit too long, it's usually possible to insert one or more auxiliary statements to clarify things.

So if you have:

IF (thisvariable - 2 * (anothervariable - SQRT(athirdvariable)) > sometestvalue) THEN resultvar = thisvariable + 3 * sometestvalue

can become:

aux1 = thisvariable - 2 * (anothervariable - SQRT(athirdvariable)
aux2 = thisvariable + 3 * sometestvalue
IF (aux1 > sometestvalue) THEN resultvar = aux2

This method is probably easier to follow and makes debugging easier.

all the best, :)

Graham

Hi Graham!
I think that Mike rather intended to talk about long API DLL declarations, as most of the time i've seen developpers using line continuation using underscore "_" was with API declaration.

Regards,
Peter.
Regards,

Peter B.

GWS

Ah yes .. of course; they do get a bit long ..  ;D .. it would improve that situation and make it easier to read ..  :)

Graham
Tomorrow may be too late ..

Mike Stefanik

July 06, 2008, 09:11:48 AM #23 Last Edit: July 06, 2008, 09:32:48 AM by Mike Stefanik
Edit: On second thought, I'm not going to drag this discussion off-topic.

Graham, he's right that I was thinking of it primarily in the context of function declarations which can get kind of lengthy. It can also be used to make code look nicer when you're calling a function that has a lot of arguments. So instead of:


nResult = SomeFunction(argument1, argument2, argument3, argument4, argument5)


You can write it as:


nResult = SomeFunction(argument1, _
                       argument2, _
                       argument3, _
                       argument4, _
                       argument5)


It just makes the code easier to read, in my opinion.
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

aurelCB

Ok Mike...
You love Vista and that is ok.
But do you realy,realy mean that Vista is much safe system then Xp?
Just one thing- before Vista oficiali see world there around has many cracked copy??
How this is possible if Vista has realy secure OS.
No one of my friends dont use Vista not becose he has old computers then becose he dont like it.
Some of them buy brand new computers and replace Vista with XP.