Jump to content
UBot Underground

[GET] Custom Append to File and Prepend to file Functions


What Do you think?  

8 members have voted

  1. 1. Was it helpful?



Recommended Posts

Hi fellows,

 

I requested this feature many moons ago here :

http://www.ubotstudio.com/forum/index.php?/topic/9325-must-have-append-and-prepend-to-file/page__view__findpost__p__47674

 

But as it is not so hard to accomplish and the Ubot Dev. team is busy I thought I'll build a custom work around till they could implement it.

 

Alright here we go:

 

 

Append to File:

 

define $append to list(#Filename, #Text To Append To List) {
   set(#list, $read file(#Filename), "Local")
   save to file(#Filename, "{#list}
{#Text To Append To List}")
}

 

Prepend to file

 

define $prepend to list(#Filename, #Text To Prepend To List) {
   set(#list, $read file(#Filename), "Local")
   save to file(#Filename, "{#Text To Append To List}
{#List}")
}

 

Usage Instructions:

 

- Copy the code provided above into your Ubot script.
- Use the functions from 
> Parameters 
 > Custom Functions
   $prepend to list
   $append to list

Drag Drop and Enjoy 

 

Here is a screenshot on where to find them:

 

http://img688.imageshack.us/img688/4519/ubotnewcustomfunctionsb.png

 

Hope it helps.

 

Cheers!

Praney

  • Like 4
Link to post
Share on other sites

Ok here is a shorter version for it:

 

Append to File:

define $append to list(#Filename, #Text To Append To List) {
   save to file(#Filename, "{$read file(#Filename)}
{#Text To Append To List}")
}

 

Prepend to file:

 

define $prepend to list(#Filename, #Text To Prepend To List) {
   save to file(#Filename, "{#Text To Append To List}
{$read file(#Filename)}")
}

 

Cheers!

  • Like 4
Link to post
Share on other sites

shortest version

strg+o c/p alt+f4

 

:) :)

 

OK... you're gonna have to explain this one... its got me stumped...

 

http://www.ubotstudio.com/forum/public/style_emoticons/default/blink.gif

 

 

 

Link to post
Share on other sites

Ok after a few splashes of Water on my eyes, I now see the problem. I added the prong variable. Here:

 

Prepend to file(Corrected)

 

define $prepend to list(#Filename, #Text To Prepend To List) {
   set(#list, $read file(#Filename), "Local")
   save to file(#Filename, "{#Text To Prepend To List}
{#List}")
}

 

define $prepend to list(#Filename, #Text To Prepend To List) {
   save to file(#Filename, "{#Text To Prepend To List}
{$read file(#Filename)}")
}

 

 

 

Hey Praney thanks for sharing. The append code works fine for me but the prepend doesn't.

 

The first prepend code (version on the OP) erases everything on the file and the second code (short version)just ads a blank space on top. Any one else having this issue?

 

Now I just need to figure out how to do the same with tables :wacko:

  • Like 3
Link to post
Share on other sites

Also if you prefer using the shell command you can use the following command:

 

cat file.txt | pbcopy && echo "Text to prepend" > file.txt && pbpaste >> file.txt

  • Like 2
Link to post
Share on other sites
  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...