CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 Creating text files on local PC

Print topic Send  topic

Author Message
mlapl1

Posts: 66
Posted: 06/19/2008, 3:29 AM

Hello all,

I have tried to wade through the docs but cannot seem to find what I am looking for.

Is there some way for CCS to create a text file on the local PC from information gathered from a query to the database? e.g. if it finds the name of an employee, can that name then be stored in a text file on the PC of the person making the query? I am sure there must be a way of doing this. I would appreciate a pointer in the right direction.

Thank you very much
Andrew
View profile  Send private message
wkempees


Posts: 1679
Posted: 06/19/2008, 5:45 AM

Create a one time file contaning that data or
do you intend to open a file and stream data into it, meaning more than one record?

walter


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
mlapl1

Posts: 66
Posted: 06/19/2008, 6:08 AM

Hello Walter - thanks as ever...

The idea is to create a file which would be recreated (not added to after it is created) from time to time with new information. It would contain information from a variable number of records depending on the result of the SQL query.

The file would then be read by another program and use the information in the file as data for whatever it intends to do.


Hope that makes sense.
Andrew
View profile  Send private message
wkempees


Posts: 1679
Posted: 06/19/2008, 6:20 AM

It does make sense.
Soap EDI like transaction handling.
Would do it the other way around though.
Have your application stream the data into a predefined file + directory, (access rights).
Commands like fopen() fwrite() spring to mind.
Have the other (slave) app pick the file up and process it, or remote open.
Why? because you wil have to overcome a lot of hurddles writing to a client station.. And in this sort of processes the lead process has the initiative, keep it.

Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
mlapl1

Posts: 66
Posted: 06/19/2008, 7:05 AM

Thank you Walter,

Yes - that's pretty much what I had in mind. So... if I understand right, I should write the appropriate code in php (hence the fopen and fwrite that you mention) and insert it somewhere in the appropriate part of the system.

OK - that makes sense. And as I understand it there are no pre-defined file-handling functions in CCS.

Cheers
Andrew


View profile  Send private message
wkempees


Posts: 1679
Posted: 06/19/2008, 10:58 AM

Just a wild example:
Create a new page, on the page a grid (with or without search).
Make the grid's SQL what you want, have it display all the fields you need.
Test it.
Now, we go for an automatic creation of a file holding that data.
Just remember you may have to do some extras to get the data the way you like.......
meaning defaulting numbers to zeroes, catering for empty fields and the likes.
But basically:
Open your just created page,
EventAfterInitialize
  
// -------------------------  
    // Write your own code here.  
// -------------------------  
	global $filehandle;  
	$filehandle=fopen("transfer.txt","w+"); // w = write, w+ = write and clear or create id not exist.  
  
//End Custom Code  

Event BeforeUnload:
  
// -------------------------  
    // Write your own code here.  
// -------------------------  
	global $filehandle;  
	fclose($filehandle);  
//End Custom Code  
Now we have craeted a file "transfer.txt" that will be writeable, clears its content when this page starts, or creates the file if it does not exist.
Now we need to fill it with data, this is dependant upon your own requirements, but

Grids'BeforeShowRow Event:
  
// -------------------------  
    // Write your own code here.  
// -------------------------  
    global $filehandle;  
    $filecontent = "";  
    $filecontent .= $Container->FieldName1->GetValue() .":";  
    $filecontent .= $Container->FieldName2->GetValue(). ":";  
    $filecontent .= $Container->FieldName3->GetValue();  
    fwrite($filehandle, $filecontent);  
  
//End Custom Code  
  

This is a basic example, using ; as delimiter.
Might need some polishing like a "/n" at the end.
Read up on file handling PHP.

Good luck.

Walter

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
mlapl1

Posts: 66
Posted: 06/19/2008, 11:25 AM

Thank you so much Walter. That will get me going.

All the best
Andrew
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.