Author Topic: Dumb String Question  (Read 2991 times)

Bandersnatch

  • Community Member
  • Posts: 7
  • Hero Points: 0
Dumb String Question
« on: January 10, 2007, 08:24:34 pm »
Hi there,

I'm a bit of a newbie to the SlickEdit thing, and I'm looking for a function that saves a string in a specified file.  I've been able to easily open a file and place the contents into a string using GetFileContents, but I can't seem to find the reverse.

Something along the lines of Put(_str filename, _str text), maybe?  Or should I be doing this a different way?

hs2

  • Senior Community Member
  • Posts: 2728
  • Hero Points: 282
Re: Dumb String Question
« Reply #1 on: January 10, 2007, 11:10:00 pm »
You can use sth. like that to (invisibly) manipulate a buffer and finally save / discard it.

Code: [Select]
...
   _str text2save = "Hello Bandersnatch";
   _str fname = "Bandersnatch.txt";

   int temp_view_id=0;
   int orig_view_id=_create_temp_view(temp_view_id);

    // do sth. more useful ;)
    bottom_of_buffer ();
   _insert_text ( text2save );

   // save it if you want
   save_as ( get_env ("TEMP") "\\" fname)

   _delete_temp_view(temp_view_id);
   activate_window(orig_view_id);
...

Have fun,

HS2
« Last Edit: January 10, 2007, 11:17:03 pm by hs2 »

Bandersnatch

  • Community Member
  • Posts: 7
  • Hero Points: 0
Re: Dumb String Question
« Reply #2 on: January 11, 2007, 02:30:07 pm »
Works Beautifully.   :)

Thanks!