Coding

 Reply to this postStart new topic

[CLEO]Writing string into a file

Mora Hannover
post Jan 12 2015, 03:40 PM
Post #1


Ameteur Member

Posts: 42
Joined: 3-November 14



The Code Works Perfectly and The Text Displays but when i open CAMPS.ini the file is empty and nothing is written.
CODE
{$CLEO .cs}

03A4: name_thread 'CAM'
wait 250

:CAMG
0@ = File.Open("CLEO\CAMPS.INI",25202)
wait 250
if
0AB0:   key_pressed 121   //F10
jf @CAMG
068D: get_camera_position_to 1@ 2@ 3@
068E: get_camera_target_point_to 4@ 5@ 6@
06D2: 7@v = "Camera Position : " // @v = string
06D2: 8@v = 7@v + 1@ + 2@ + 3@ // @v = string
06D2: 9@v = "Camera Target Point : "
06D2: 10@v = 9@v + 4@ + 5@ + 6@
0AD8: write_string_to_file 0@ from 8@v //IF and SET
0AD8: write_string_to_file 0@ from 10@v //IF and SET
0ADF: add_dynamic_GXT_entry "Cam1" text "Positions Saved in CamPs.ini"
00BC: show_text_highpriority GXT 'Cam1' time 9000 flag 1
0AE0: remove_dynamic_GXT_entry "Cam1"
File.Close(0@)
jump @CAMG
end_thread


--------------------
Rest in Peace Yeardley Diamond (Dec. 21, 1985 - Aug. 20, 2014)
Rest in Peace Kitty0706 (1994 - Jan. 25, 2015)
Go to the top of the page
 
+Quote Post
Deji
post Jan 14 2015, 08:07 AM
Post #2


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Don't use a number to open the file, use "w".
Don't use class.member format, it's stupid
Escape the backslash in "CLEO\CAMPS.INI"
Actually try checking the file has opened.

"Camera Position : " is too long to fit in a standard string variable. Even if it wasn't, the other variables you use share the memory you're storing to.

This shouldn't and probably doesnt even compile...
CODE
06D2: 8@v = 7@v + 1@ + 2@ + 3


Why use an ini file when writing in binary or plain text?

Why add a dynamic text label, only to remove it after a single use which could have been replaced ny CLEO 4's dynamic PRINT command?

end_thread is useless in your script, plus it isn't for normal usage in a CLEO script.

Basically every single line of that code is wrong in some way... I recommend going back to tutorials in coding or sticking to modelling.


--------------------
Go to the top of the page
 
+Quote Post
Mora Hannover
post Jan 14 2015, 09:26 AM
Post #3


Ameteur Member

Posts: 42
Joined: 3-November 14



Thanks for your support
Honestly, This was a personal script , i made to make cinematic views in my mission pack with cam hack. Anyways i will continue to make tutorials as you said


--------------------
Rest in Peace Yeardley Diamond (Dec. 21, 1985 - Aug. 20, 2014)
Rest in Peace Kitty0706 (1994 - Jan. 25, 2015)
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: