Welcome! Log In Create A New Profile

Advanced

Text,Numeric,Currency Questions

Posted by Paul 
Paul
Text,Numeric,Currency Questions
April 12, 2008 06:15PM

When creating a file item of type text- if I assign the maximum length to be 5000 characters and the user does not enter anything into it, or enters a lesser amount of characters, how much memory is used to save it? Just what is entered or the memory space for 5000 characters?

Numeric or Currency: To be sure there is no rounding error should I type the File Items as Numeric or Currency? In the Win Express 10 demo, it seemed to say use Currency. However, I remember reading something in the Win 11 documentation that indicated you should use Numeric.

Any answers are greatly appreciated.

Paul Ziegler
Private Advantage Software
Chris L
Re: Text,Numeric,Currency Questions
April 13, 2008 09:04AM
Paul

Text can actually be stored in three different ways. Character as its name suggests stores just one character and is therefore of rather limited use and could really be left out of the language. String is the most useful and most used type for text; it has a maximum limit of 65 535 characters. The third type Text memo can take a character string up to 4 GB (which should be ample for most purposes!); this is particularly useful for notes because text memos support RTF formatting.

Whether you use strings or text memos, the size is dynamic, ie only the storage space required is used. Add some more text (to either a string or memo) and your file size will increase, and vice versa.

So if you have specified a string with a maximum length of 5000 characters, the user can enter up to 5000 characters (but no more) but if nothing is entered, no space will be used. If you're declaring a variable in your program of string type, then no length is specified (although the 65K limit still applies).

[If you're interfacing your WD with another programming language, then there are some variants of the string type to ensure compatibility with the other language but if it's just a WD application then you only need the standard string or text memo types.]

Numeric vs currency. In the past, I've always stuck with currency for numeric calculations which need to be exact with no rounding off error, typically monetary/financial calculations. My understanding is that WinDev used a form of what used to be called BCD, binary-coded decimal. However, in checking out the Help information in version 11, it seems that the currency type has now been superseded by the numeric type so obviously numeric is also a BCD type. Simply put, it seems that numeric is the same as currency but with a greater number of digits: currency can contain up to 23 significant digits, 17 for the integer part and 6 for the decimal part, while numeric can have up to 38 significant digits, 32 for the integer part and 6 for the decimal part.

The Help file says that the currency type is kept for backward compatibility which suggests that this may be phased out in some future time in favour of the numeric type. However, given PC Soft's past record of keeping backward compatibility for quite a few versions hence, there's no need to drop currency in a hurry unless you need the extra precision. Although the currency type is faster because of the lower precision, my inclination would be to use the numeric type as this looks to be WinDev's future path.

Hope this is of use.

Chris
Melbourne, Oz

Paul
Re: Text,Numeric,Currency Questions
April 13, 2008 05:42PM
Chris,

Thanks! This was exactly the information that I needed.

Paul
P.H.
Re: Text,Numeric,Currency Questions
April 14, 2008 12:20AM
A small correction to the sizes of a string variable if I recall correctly...
- As a definition in a datafile (=field) the limit is indeed 65535 except for binary text memo fields)
- As a variable in code the limit is 2GB or 4 GB depending if you're running a 32 or 64 bit operating system. That's why you can treat a binary text memo from a data file in a string variable in code...

Cheers,

P.
Chris L
Re: Text,Numeric,Currency Questions
April 14, 2008 05:36AM
Thanks, Paul, that's something I hadn't realised/known. I use the text memo fields quite a bit for storage of notes of all sorts because of the RTF formatting capability but I must admit that I haven't needed to manipulate these items in code.

C.
Author:

Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: