Welcome, Guest. Please login or register.
Did you miss your activation email?

Username: Password:


Pages: [1]   Go Down

Author Topic: Make pleo write to a file  (Read 2279 times)

alunoist

  • Leaving the nest
  • * Posts: 8
  • Female
Make pleo write to a file
« on: July 29, 2010, 03:15:15 AM »

Hi,

I need help with my school project.
I have a specific behaviour for pleo in my sd card. I would like to know if its possible to make pleo write to a file.

For example if I touch the back sensor I would like for pleo to write to a text file that exists on the sd card something like "back sensor has been touched".

Is it possible? If so could you post the piece of code that does that.

Thanks
Logged


InmemoryofRomeo

  • Global Moderator
  • Pleo Grand Master RB
  • * Posts: 6903
  • au Female
  • Pleo(s): Lilo, Stitch, Pleakley, Jumba, Nani, Yuki, Angus, Pluto
  • : 2011 winner2009 winnerTomato Harvest Festivals
  • SAVE THE EARTH It's the only planet with chocolate
    • Professor
    • Wile_E_Coyote
    • Marcie
Re: Make pleo write to a file
« Reply #1 on: August 01, 2010, 06:20:33 PM »

Free bump to remind people, you need one of the smart peeps to come on.
Logged
Eagerly awaiting Vector and Blue!

ohnart

  • Pleo explorer
  • * Posts: 123
  • Male
  • Art + Science = Pleo
Re: Make pleo write to a file
« Reply #2 on: August 02, 2010, 12:13:36 AM »

Cant help you, but it would be an awesome project!
Logged
Science + Art = Pleo

PleoPet

  • Pleontologist
  • * Posts: 162
  • Female
Re: Make pleo write to a file
« Reply #3 on: August 03, 2010, 06:31:49 AM »

>  I would like for pleo to write to a text file that exists on the sd card something like "back sensor has been touched".
Look at the File functions of the PDK (in File.inc) and the file_example example.



    device_change(device_sd);
        // put it on the SD card

    new File: file_handle = file_open("whatever.txt", io_write);
        // opens file for writing, will replace old contents
        // you may want "io_append" if you want to keep a longer log

    if (!file_handle)
    {
        // oops - file was not created
        // do something to handle the error, perhaps file locked
    }
    else
    {
        // write to file, and close
        file_puts(file_handle, "back sensor has been touched");
        file_close(file_handle);
    }

Logged

alunoist

  • Leaving the nest
  • * Posts: 8
  • Female
Re: Make pleo write to a file
« Reply #4 on: August 06, 2010, 06:45:41 AM »

Thanks pleopet!!

I will test the code.
Logged
Pages: [1]   Go Up
 

SimplePortal 2.3.5 © 2008-2012, SimplePortal