Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, AndrewAMD), 911 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
AUM 66 file handling #292744
10/06/09 14:56
10/06/09 14:56
Joined: Aug 2003
Posts: 63
UK
ptrc1c Offline OP
Junior Member
ptrc1c  Offline OP
Junior Member

Joined: Aug 2003
Posts: 63
UK
Hi George
I had a use for your code from the workshop in AUM 66.
Following the tutorial I found that I could enter a string,
but after entering it I could only get the flashing cursor, it
was supposed to wait until another string was entered or the string "end" to terminate. What I found was the code used str_cpy to set the string back to "". I found this command reset the string, which originally was declared to have 20 characters, back to 0 characters. It would therfore never terminate because it would not accept strings of any length.
Here is the code I got to work. ps I have also modified the on_key command to be in main.



////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>


var string_handle;



STRING* string_str = " "; // the string can store up to 20 characters



TEXT* string_txt =

{

pos_x = 20;

pos_y = 200;

string (string_str); // player's input will be stored inside this string

flags = VISIBLE;

}



function write_strings() // writes and appends strings

{

// string_txt.visible = ON; // make the text visible (displays the cursor as well)

string_handle = file_open_append("strings.txt"); // open this file for appending (create it if it doesn't exist)

while (1)

{

inkey (string_str); // store the input inside the string named string_str

if (!str_cmpi(string_str, "end")) // if the player didn't type "end" yet

{

file_str_write (string_handle, string_str); // the string is written inside the "strings.txt" file

file_asc_write (string_handle, 13); // write the following string on a separate line

file_asc_write (string_handle, 10); // using asc(13) = carriage return + asc(10) = line feed

str_cpy(string_str, " "); // reset the input string - makes the input look better


}

else // the player has typed "end"

{

break; // so we exit the "while" loop

}


}

file_close (string_handle); // close the file, we won't be needing it from now on

sys_exit(NULL); // shut down the engine

}

void main()
{


on_f3 = write_strings;


}

Edit the spaces betwwn the quotes should be longer, dont know why its being truncated in this script

Last edited by ptrc1c; 10/06/09 15:05.
Re: AUM 66 file handling [Re: ptrc1c] #292804
10/07/09 07:33
10/07/09 07:33
Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
George Offline

Expert
George  Offline

Expert

Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
The engine has changed a bit since then; now you can reset a string using something like str_cpy(my_string, "#20");

Re: AUM 66 file handling [Re: George] #292834
10/07/09 12:08
10/07/09 12:08
Joined: Aug 2003
Posts: 63
UK
ptrc1c Offline OP
Junior Member
ptrc1c  Offline OP
Junior Member

Joined: Aug 2003
Posts: 63
UK
George
Thanks for the reply. I had a bit of a problem when doing another part of the workshop. Again the problem was the string declared in the str_for_asci command needed to have the ability to store at least one character or it gave an empty pointer error when the script was run. Thanks


Moderated by  George 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1