Author Topic: how to create/rewrite a file  (Read 964 times)

0 Members and 1 Guest are viewing this topic.

Offline chase is my name

  • Major(1)
  • Posts: 19
how to create/rewrite a file
« on: July 24, 2007, 03:57:34 pm »
I looked through the forum headers and didn't see a topic relating to this so sorry if this has already been addressed before.

Motive: To create or rewrite my bot files

Problem: We have the WriteLnFile command to apppend (add) text to an existing file but no rewrite or create file command. I tried using the raw pascal equivalent, but there is no such variable as a textfile, and therefore i can't assign a file handler to the ReWrite Pascal command. If we had access to the Pascal ReWrite command then we could create/rewrite i  believe. Any workaround to this or something i'm missing?

Problem: The second problem is that the bots folder is a subdirectory of the soldat directory. I was thinking of getting around this by putting shortcuts in the bots folder and the actual bot files themselves sitting in the soldat directory. Would this work?

Thanks
Chase is my name

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: how to create/rewrite a file
« Reply #1 on: July 24, 2007, 04:07:49 pm »
You can use these:

WriteFile
ReadFile
urraka

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: how to create/rewrite a file
« Reply #2 on: July 24, 2007, 04:11:13 pm »
WriteFile(Filename,text:string);

WriteFile also automatically overwrites old files, so it fits your purpose of rewriting. here's an example which would create a .bot file, chr(13) + chr(10) are linebreaks.

Code: [Select]
WriteFile('/bots/Boogie Man.bot','[BOT]' + chr(13) + chr(10) + 'Name=Boogie Man' + chr(13) + chr(10) + 'Color1=$00663633' + chr(13) + chr(10) + 'Color2=$00663633' + chr(13) + chr(10) + 'Skin_Color=$00FFF1F0' + chr(13) + chr(10) + 'Hair_Color=$00010101' + chr(13) + chr(10) + 'Favourite_Weapon=Chainsaw' + chr(13) + chr(10) + 'Secondary_Weapon=0' + chr(13) + chr(10) + 'Friend=' + chr(13) + chr(10) + 'Accuracy=0''Shoot_Dead=0' + chr(13) + chr(10) + 'Grenade_Frequency=10000' + chr(13) + chr(10) + 'Camping=255' + chr(13) + chr(10) + 'OnStartUse=255' + chr(13) + chr(10) + 'Hair=0' + chr(13) + chr(10) + 'Headgear=0' + chr(13) + chr(10) + 'Chain=0' + chr(13) + chr(10) + 'Chat_Frequency=222' + chr(13) + chr(10) + 'Chat_Kill=' + chr(13) + chr(10) + 'Chat_Dead=' + chr(13) + chr(10) + 'Chat_Lowhealth=' + chr(13) + chr(10) + 'Chat_SeeEnemy=' + chr(13) + chr(10) + 'Chat_Winning=');
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline chase is my name

  • Major(1)
  • Posts: 19
Re: how to create/rewrite a file
« Reply #3 on: July 24, 2007, 04:25:53 pm »
domo arigato mr avarax,

you did what no amount of googling or forums searching could. you are a rock star for me at the moment :)

btw where is there a comprehensive list of such soldat commands? Enesce's sute didn't have this command

Date Posted: July 24, 2007, 05:24:25 PM
woops i wrote too soon,

i just refreshed his site which i havnet done in 6 months

i see them now. Thanks :)

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: how to create/rewrite a file
« Reply #4 on: July 24, 2007, 04:39:23 pm »
dont cum
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline chase is my name

  • Major(1)
  • Posts: 19
Re: how to create/rewrite a file
« Reply #5 on: July 24, 2007, 05:13:59 pm »
ugh...that's so inappropriate lol

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: how to create/rewrite a file
« Reply #6 on: July 24, 2007, 10:41:46 pm »
lmao
there are some pascal commands that aren't shown in enesce's help that you might find useful!

One that I found useful was the Delete(string, start_position, end_position);
for example:
MyString := 'Hello You Foolish man';
Delete(MyString, 7, 17);
WriteLn(MyString); // will display 'You Foolish'
Can't think of anything original to put here...