(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
06-26-24 10:59 AM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - Ok I want to build a code editor but... New poll | |
Add to favorites | Next newer thread | Next older thread
User Post
darkwitch

Red Cheep-cheep


 





Since: 10-16-06
From: Puerto Rico

Last post: 6337 days
Last view: 6337 days
Posted on 10-26-06 11:01 PM Link | Quote
Im not too good in ( fopen() fclose() fread() fwhatever() )

So anybody care to explain a little in deep how those work?
Will this work:
require blablabla;

$file = fopen($filename);
$content = fread($file);
<"txta=text ROWS=100 COLS=100">$content<""/TEXTAREA"">
$inph=action VALUE=savefile>
$inps=submit VALUE=\"Save File\"><""/TD"">

if($action=blaablablabla){
fput($file) = $text;
print" blabalablabal";
?>

Please ignore the quotes, not adding them would do ugly things.
Will that crap work (most likely not).I just want to know where I have errors to learn from my mistakes
Kailieann



 





Since: 11-18-05

Last post: 6337 days
Last view: 6337 days
Posted on 10-27-06 09:17 AM Link | Quote
With regards to the quotes..

&#60; = <
&#62; = >
darkwitch

Red Cheep-cheep


 





Since: 10-16-06
From: Puerto Rico

Last post: 6337 days
Last view: 6337 days
Posted on 10-31-06 08:47 AM Link | Quote
Thanks Kailieann Now I know a way to post codes properly

But I still am confused with the codes I mentioned earlier
rubixcuber

Mole








Since: 09-08-06
From: St. Louis, MO

Last post: 6446 days
Last view: 6446 days
Posted on 10-31-06 12:34 PM Link | Quote
Well, you didn't say but I'm going to assume PHP because of the $ prefix on variables and the ?>. If it's not PHP, most of it should still apply though.

First of all, fopen requires a second argument. You need to specify the mode you want to open the file in.

Second, you have to tell fread how much data to read in. There are a couple ways to do this. You can check the file size and have fread read in that much data, or do a loop checking for the end of file and reading data if not at the end of the file yet.

Third... this is the part that makes me wonder what language this is. In PHP fput is called fputs. And you pass the text as an argument. So this would be the way in PHP:

fputs($file,$text);

Also you need to close the file. Call fclose($file) when you are done using it.

Here's my revised code:

$file = fopen($filename ,'r'); //open file for reading
$content = "";
while(!feof($file)){ //while not at end of file
$content.=fread($file,1); //read one byte of the file
}
fclose($file); //close the file
//I assume you want to print the next line. If PHP I think you need echo or some equivalent function
<"txta=text ROWS=100 COLS=100">$content<""/TEXTAREA"">
$inph=action VALUE=savefile>
$inps=submit VALUE=\"Save File\"><""/TD"">

if($action=blaablablabla){
fopen($file,'w');//open file for writing (this will erase the file is you want to append use a instead of w)
fputs($file,$text); //write to file
fclose($file); //close the file
print" blabalablabal";
?>

Hope that helps a bit.
darkwitch

Red Cheep-cheep


 





Since: 10-16-06
From: Puerto Rico

Last post: 6337 days
Last view: 6337 days
Posted on 10-31-06 04:52 PM Link | Quote
Ok, thanks

Im going to test it right away.

And yes, I was talking about PHP .
Black Lord +

Flurry


 





Since: 11-17-05
From: Where indians still roam...

Last post: 6339 days
Last view: 6340 days
Posted on 11-10-06 07:21 PM Link | Quote
Originally posted by rubixcuber

//I assume you want to print the next line. If PHP I think you need echo or some equivalent function
<"txta=text ROWS=100 COLS=100">$content<""/TEXTAREA"">



Or he could close the php script, put the next line, and then open it back up via

?>
<txta=text ROWS=100 COLS=100> $content </TEXTAREA>
<?



(edited by Black Lord + on 11-10-06 06:22 PM)
(edited by Black Lord + on 11-10-06 06:23 PM)
(edited by Black Lord + on 11-10-06 06:24 PM)
Add to favorites | Next newer thread | Next older thread
Acmlm's Board - I3 Archive - Programming - Ok I want to build a code editor but... |


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.011 seconds; used 375.39 kB (max 453.27 kB)