[Implemented] Redim PRESERVE

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Akuma no Houkon
User
User
Posts: 77
Joined: Sun Nov 02, 2003 1:47 pm
Location: Washington
Contact:

[Implemented] Redim PRESERVE

Post by Akuma no Houkon »

In PureBasic, you can resize an array with DIM but as the helpfile states all data in the array is lost. In all programing languages I have ever used there was some optional keyword that allowed you to redim an array and KEEP the original data intact (unless of course you dim it to a smaller size you of course lose what was trimmed off) In most basic dilects this comes in the form of

REDIM MyArray(ArraySize)
OR
REDIM PRESERVE MyArray(ArraySize)

From the documentation I dont see any such command.
Now im sure you can manually make a copy of the memory, redim the array and plop the data back down on it. But the point of high level languages is to simplify the programing proccess.

It would be nice to see such a function in PureBasic.
AMD 2600+, nVidia Geforce FX 5200 128 MB DDR, 512 DDR, RedHat 9
Balatro
User
User
Posts: 15
Joined: Sun Oct 05, 2003 2:27 pm

Post by Balatro »

I agree -- I know it would make certain things much easier for me.

~ B
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Suppose this is already on the ToDo list:

viewtopic.php?t=7988&highlight=redim

viewtopic.php?t=6160&highlight=redim

You know there is a search function in this forum....
Akuma no Houkon
User
User
Posts: 77
Joined: Sun Nov 02, 2003 1:47 pm
Location: Washington
Contact:

Post by Akuma no Houkon »

fsw wrote:You know there is a search function in this forum....
Not a very good one.
It either returns no results, or a ton of results (which usually have nothing to do with what you are searching for) so I dont even bother anymore.

Not to mention PureBasic names their commands some of the oddest things that are not common names, so trying to search for them are pointless.

I tried searching for Command$ (which it is in nearly every basic dialect), Command(), CommandLine, etc... about 10 differnt options, and FINALLY stumbled upon "ProgramParamater" ?? Same for things like "MessageRequester", which every basic dialect uses "MsgBox". To me, comming from these other languages, trying to search for functions that may exist or may be on the list to do, is nearly pointless.
AMD 2600+, nVidia Geforce FX 5200 128 MB DDR, 512 DDR, RedHat 9
Codemonger
Enthusiast
Enthusiast
Posts: 384
Joined: Sat May 24, 2003 8:02 pm
Location: Canada
Contact:

Post by Codemonger »

I get the same problem searching, it returns a ton of results so I click on the option "Search for all terms" when I do a search, that way it narrows it down pretty good.

I also had the same problem switching from VB to PB, with certain commands. Thats something that just takes time to get used to. Now I don't even wan't to go back to VB. Also I don't think PB fits in the High Level programming language, or the Low Level programming language. I think it is in between. Nice Mix 8)
<br>"I deliver Justice, not Mercy"

    - Codemonger, 2004 A.D.
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Easily solved with mem banks. Just watch out for any cached addresses.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Not a very good one.It either returns no results, or a ton of results (which usually have nothing to do with what you are searching for) so I dont even bother anymore.
Searching any glob of text is frustrating for sure. Be careful what you're searching on and don't expect perfect results. Sometimes you won't find anything on the forum, other times you'll have way too much information!
I tried searching for Command$ (which it is in nearly every basic dialect), Command(), CommandLine, etc... about 10 differnt options, and FINALLY stumbled upon "ProgramParamater" ?? Same for things like "MessageRequester", which every basic dialect uses "MsgBox". To me, comming from these other languages, trying to search for functions that may exist or may be on the list to do, is nearly pointless.
That has nothing to do with the forum search and everything to do with you needing to read the PureBasic documentation. Every language does things it's own way and PB is no exception. Reading through the help file will give you a good idea on what things are called and how to get more information from the forum. The docs do need work but things like what you just outlined are covered pretty well.

Good luck! :-)
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Akuma no Houkon
User
User
Posts: 77
Joined: Sun Nov 02, 2003 1:47 pm
Location: Washington
Contact:

Post by Akuma no Houkon »

That has nothing to do with the forum search and everything to do with you needing to read the PureBasic documentation. Every language does things it's own way and PB is no exception.
But purebasic has BASIC in its name and claims to follow BASIC language standards, which it BARELY does. You cannot search for something on the help file if you have no clue what the name is. I must have passed MessageRequester 100 times on the help doc and never figured it out, it wasnt until I stumbled upon it in an example demo that I realized what it was. Each language has its own commands and style, of course, but most languages follow common ground to lower the learning curve. Not to mention something like MessageRequester is a pain to type over and over and over again (I use about 100 message boxes or more in my app), its kind of pathetic that I have to write a Procedure to wrap MessageRequester into a smaller name "MsgBox" which all other dialects of basic already have. (macros would come in handy in these situations, allowing those of us that want things named "properly" can simply write macros for them rather than wrap them into actual procedures)
Now I don't even wan't to go back to VB.
Its not hard to oust VB. Its a slow, bulky, bloated language that requires a 1.4 MB runtime for a hello world app (not to mention the exe size is huge as well) . VB doesnt even compile to true native code. It compiles to part native part pcode (even with the native option choosen), I gave up VB along time ago for PowerBasic, but unlike PureBasic, I was able to copy and paste 99.9% of my VB code into PowerBasic (a language that follows basic standards), In purebasic I cannot even copy %5 of my code over, EVERY LINE has to be rewritten in the mixed PureBasic langauge. Not saying its a bad language, far from it, its a very good start, but it shouldnt call itself basic. :P

But this topic has strayed far from its original purpose. ReDim Preserve would be a nice addition to the commands of purebasic. If this is already on the todo list, put another check by it for me :) No need to argue further :) My goal is the same as yours, to offer my input to help PureBasic grow into a mature language. All of my input is given based on many many years of basic programing. PureBasic is very much so worth its price, in my opinion there isnt a better linux programing language available. But there are still some changes / additions I would like to see.
AMD 2600+, nVidia Geforce FX 5200 128 MB DDR, 512 DDR, RedHat 9
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

> But purebasic has BASIC in its name and claims to follow BASIC language standards

So... what's basic standart then? Is everything VB does automatically called a standart?

I can't find any document on the net describing the *official* basic
standart. Maybe you can...

IMHO, basic defines the general syntax. Like we use words like Repeat/Until
instead of some cryptic {} notations. The naming of the individual functions
doesn't have much to do with it.

The PureBasic way of naming functions, simply: full names, that describe
the functions purpose. IMHO, that's much better to learn for a newby than
than those shortcuts, most other languages use. btw, that's what basic
stands for: an easy to learn language.

btw, if all languages would be ecactly 100% code compatible, they would
all be the same language (just different compilers)


I'm a bit tired of everybody thinking that PureBasic should be like
every language they used before. PB has it's own special mix, and
that's what makes it so good.

Timo
quidquid Latine dictum sit altum videtur
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

hey timo, don't get carried away :-)

yea, i *love* purebasic, but there is nothing wrong with a little improvement, and you can't blame other people for preferring what they were used to...

in fact, i have to agree with both of you :twisted: there is no 'standard' but now and again it would be nice if purebasic would somewhat conform to the way other basics do things :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

The PureBasic way of naming functions, simply: full names, that describe the functions purpose. IMHO, that's much better to learn for a newby than than those shortcuts, most other languages use. btw, that's what basic stands for: an easy to learn language.

btw, if all languages would be exactly 100% code compatible, they would
all be the same language (just different compilers)

I'm a bit tired of everybody thinking that PureBasic should be like every language they used before. PB has it's own special mix, and that's what makes it so good.
I whole heartedly agree with this statement!
--Kale

Image
Akuma no Houkon
User
User
Posts: 77
Joined: Sun Nov 02, 2003 1:47 pm
Location: Washington
Contact:

Post by Akuma no Houkon »

The PureBasic way of naming functions, simply: full names, that describe
the functions purpose
So by your concept, MessageRequester should ACTUALLY be

SmallModalDialogBoxWithTextAndOptionalButtonsAndIcons

You have to draw the line somewhere.

"MessageRequester" ?? how does that describe what it does? I am not REQUESTING anything. Just a simple box with text on it and an OK button. No requests, more like NOTIFICATIONS.

As for the "Standard" of basic, I can take atleast 70% of my code and copy and paste it into 5 or more differnt basic languages WITHOUT modification. That is standards. I have NEVER seen Repeat:Until in ANY basic language. All other basics have DO : LOOP or DO : UNTIL, even when PureBasic gives common functions they give uncommon names, making porting of code a pain in the ass.
btw, that's what basic
stands for: an easy to learn language.
BTW, It has nothing to do with being easy, Beginers Allpurpose Symbolic Instruction Code. It mentions beginers but never easy.

But if your going to have the same commands as the 20+ other dialects out there, WHY OH WHY name them something different? You talk about easy to learn, if you keep the same names for the same functions its ALOT easier for people coming from any other basic background, to learn PureBasic.

Just another reason to add macros, so we can change the language back to a real basic syntax so porting will be alot easier.

I am not saying PureBasic should be "some other language" I am saying they shouldnt claim they "All BASIC keywords are supported" when that is an outright lie.
Last edited by Akuma no Houkon on Mon Nov 10, 2003 6:39 pm, edited 1 time in total.
AMD 2600+, nVidia Geforce FX 5200 128 MB DDR, 512 DDR, RedHat 9
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

Akuma no Houkon wrote:
The PureBasic way of naming functions, simply: full names, that describe
the functions purpose
So by your concept, MessageRequester should ACTUALLY be

SmallModalDialogBoxWithTextAndOptionalButtonsAndIcons

You have to draw the line somewhere.
Yes and Fred has drawn his line with MessageRequester()
"MessageRequester" ?? how does that describe what it does? I am not REQUESTING anything. Just a simple box with text on it and an OK button. No requests, more like NOTIFICATIONS.
You request input of some sort, be it OK, YES, NO or CANCEL
As for the "Standard" of basic, I can take atleast 70% of my code and copy and paste it into 5 or more differnt basic languages WITHOUT modification. That is standards. I have NEVER seen Repeat:Until in ANY basic language. All other basics have DO : LOOP or DO : UNTIL, even when PureBasic gives common functions they give uncommon names, making porting of code a pain in the ass.
Yes, if Fred's aim was to make another VB clone or whatever then he has failed misserably...
BTW i never ever liked the DO-loops in other languages..
Akuma no Houkon
User
User
Posts: 77
Joined: Sun Nov 02, 2003 1:47 pm
Location: Washington
Contact:

Post by Akuma no Houkon »

You misunderstand Pupil, Fred CLAIMS PureBasic support ALL BASIC KEYWORDS, (from a quote on the main site) which is a lie, an over exageration. If it supported ALL basic keywords (like the site says) it would have things such as DO : LOOP and a list of probably 100+ more commands. Although in most cases it supports those FUNCTIONS it does NOT support those KEYWORDS. :) A big differnce.

I am not saying purebasic is a bad language, like I said I havent found better for linux yet (though I would never use it for windows). I am saying its false advertisement. They should not say such things when they are not true. I picked up purebasic and started to search the help file for all the basic keywords that I have used in every basic dialect I have ever used (commands that have become standard over the past 20 years). And I find about 1 out of every 30 that use the basic keywords. ATLEAST he can add those commands to the help file and link them to the actual purebasic command, so those of us from differnt backgrounds can still find the proper command.
I'm a bit tired of everybody thinking that PureBasic should be like every language they used before. PB has it's own special mix, and that's what makes it so good.
Not really, it IS like every other language (with just a TINY unquieness), except it just renames the commands. It still has most of the same commands except they have odd, uncommon, names.

But again we stray far from the original topic, why not let it die? I have said my peice and obvously its already been said before, so this topic does not need to continue.

I am not going to stop using PureBasic because of these flaws, and still recommend it for all my linux friends that want to program in linux, but nothing will ever change unless you say something, and im saying something. I am sure fred would be more than willing to create aliased commands, so purebasic can follow more closly to the standards yet still give the same old functions that it always has.

If so I would be more than willing to make up a nice list for him.
AMD 2600+, nVidia Geforce FX 5200 128 MB DDR, 512 DDR, RedHat 9
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

OK :)
As i see it the BASIC keywords are IF:ELSEIF:ELSE:ENDIF, FOR:NEXT, WHILE:WEND, REPEAT:UNTIL, SELECT:CASE:ENDSELECT, DIM, GOTO, GOSUB, RETURN, RESTORE, AND, OR etc. (there are a few more but they just don't come to mind right now).

And in my opinion most, if not all, are supported and are named the same in PB as in many other BASIC dialects..
Last edited by Pupil on Mon Nov 10, 2003 7:13 pm, edited 1 time in total.
Post Reply