Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a little confused about the transform() function problem 5

bharons

Technical User
Jan 23, 2019
49
ID
after I created a cursor in vfp and filled it in with some data. I found a problem with the asterix value in my report. Is there something wrong with my writing format as mentioned below?

Code:
create cursor skedul1 (norekening N(13), ke N(2), pokok_kr N(12), bunga_kr N(12), pokok_sd N(12))
insert into skedul1 (norekening, ke, pokok_kr, pokok_sd, bunga_kr) values (1312124120052, 1, 0, 26400, 850000)
insert into skedul1 (norekening, ke, pokok_kr, pokok_sd, bunga_kr) values (1312124120052, 2, 0, 26400, 850000)

then on command button with code below

Code:
select skedul1
mket01 = transform(skedul1.norekening,"999.99.9999.9999")
mket02 = skedul1.ke
mket03 = transform(skedul1.pokok_kr,"999.999.999.999")
mket04 = transform(skedul1.pokok_sd,"999.999.999.999")
mket05 = transform(skedul1.bunga_kr,"999.999.999.999")

REPORT FORM "E:\My Foxy\Vfp8\Report\myslip.frx" PREVIEW

report gives me an asterisk for mket01 = ***.**.****.****
Meanwhile for mket02 to mket 05 there are no problems.

Are there really any problems in writing my coding?
I'm using VFP 8...

before and after I thank you for your guidance
 
Solution
I think the problem is that the number is bigger than VFP can handle. Try this formula instead:

Update: Store the value as a string instead, c(13), since that's what it really is. Then you can use
i write your code at my command button and i run it.. it is work like i want..
mket01 = Chrtran(transform(skedul1.norekening,"@R ###-##-####-####"),'-','.')
And even with all that in mind. The different formatting characters are explained in the help documentation of TRANSFORM, and the dot "." has the meaning of decimal point in formatting a number to a string. There always is only one decimal point, so it'll only be taken into account the first time it appears in the format string. If you want to have a dot in multiple places, you're lost with TRANSFORM, as the dot has only one meaning for decimal point. Characters that you can use as spllitting characters are any that have no formatting meaning. So you're limited with the formatting as some characters have special meaning and can only be used for that special meaning and nothing else, not as literally themselves, in many cases.

Even the first dot may not show as a dot, what matters is what you have in SET("POINT"), and when you use SET SYSFORMATS on that'll be determined by system (Windows) settings for the decimal point. In many countries that's not the point but the comma. And what shows in places of a formatting character "," is the thousands separator, which in UK/US would be a comma, typpically, in countries where the decimal point is a comma it's the point, typically, so the two characters in the result are swapped. Still the format mask always has to use the dot or point (.) for the decimal point and comma (,) for thousands separator.

Since a number can get into millions, billions, trillions, etc. you can put multiple commas, multiple thousands separators into a format string, and you don't even have to space them between groups of three 9s. That makes it quite like comma is no special format character, but if your number is below a magnitude needing multiple separators, they don't show in whitespace, they only appear once they are needed for larger numbers. That's the way they are special format characters.

What remains is, that you can use many characters as literally just themselves appearing in the result of the transformation, but not the characters that have format functionality. So if you need literally have commas and points in the end result, you have to put them in post processing of the TRANSFORM result.
It's complex with SQL Server. I only understand that VFP is probably only skin deep. So I hope that the experts will provide guidance to me, a newbie.. 🙏
 
CRUD stands for CREATE, READ, UPDATE, DELETE, but most of the time is not only about these actions only, but about using http requests for that. POST or PUT for creating, GET for reading, POST or PUT for updating, and DELETE for deleting.

With SQL Server you don't use http requests, you make an ODBC connection and send SQL. SQL also has queries for CREATing records (INSERT), for READING records (SELECT), for updating records (UPDATE) and for deleting them (DELETE). This compares to CURD in the way the four actions are available, because how could you have anything else? Even if you use pen and paper you create "data" by using the pen on the paper, can read the paper, you can strike thru and write something else (update) and you can throw away the paper. So these four basic actions always exist, technologically or not, about data, you can't avoid that.

But the main thinking of SQL differs very much from CRUD. CRUD uses a URI as an identifgier of a resource that's located at that URI, that can be something like a single value, a record in json format or XML, a whole json document, etc, whereas SQL is all about tables in databases, the SQL cares mostly about records, but not just a single record in many cases (i.e. with SELECT you can select a whole table, even join muiltiple tables). The data is not organized at some URI but within a database and tables within the database.

So they compare, but differ very much at the same time. Don't think about CRUD when you think about databases, because databases work by SQL, some NOSQL databases working more closely to the CRUD principle also exist, but MSSQL Server is a relational database management system (RDBMS) and while data is commmon to both principles and sql also is about the actions of creating, reading, updating and deleting data (the data lifecycle) the means to do that differ very much. Think alone about SELCT enabling you to pick from the range of a single fiield of a single record to multiple joined tables of data. You're not comparing apples with oranges but apples with spacestations.
hay Chris.. my teacher.. :giggle:
maybe all the problems that i got just in langguage barriers... 🤭.. but i will learn it any way..
 

Part and Inventory Search

Sponsor

Back
Top