2 registered members (dr_panther, 7th_zorro),
1,203
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Three more questions
[Re: lemming]
#444921
08/21/14 21:47
08/21/14 21:47
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
I was seriously disappointed when in the main you only commented every second line. I was quite unable to understand what you where trying to do, mainly because your comments killed your code. My favorite lines where:
// set it's layer:
layer = 1;
// no strings:
strings = 0;
// wait one frame:
wait(1);
Yes, I have to agree with you man.. And you aren't actually a first person who told me about my useless comments for each line... And even more, I have to say that it's became some kind of a paranoia, so I can't code anything without simply commenting each line This comments aren't just useless.. but they are ridiculous in most cases and they ruined the whole idea of what are they were made for. About the problem I have (SECOND PROBLEM - still not fixed, all other ones are fixed already). In order to describe the problem, I probably need to explain how the code works (the one I've posted above). It's pretty simple so far: 1. 'file_for_str' reads .txt file line by line till delimiter 2. data which was read from the .txt file is sent into global pointers (vars, strings). (f.e. you see that 'document_page' in the .txt file, and I have same string in the code, this function will fill up the string with the text from .txt file automatically! this helps me to read such things like 'document title' or 'amount of max pages per document' for each document separately from one .txt file). This is very simple approach yet it allows me to read unlimited amount of pages and documents from single .txt file and organize them well. Current problem is, that string wasn't read completely from the file, maybe the loop was broken before the function finished reading it, I'm not sure. The function that actually reads document text into 'document_page' string is - 'loadDoc(id)', you can see it in the for loop (line 95). Also right there, before that 'for' loop you can see that I run 'file_for_str' again, that will read the very first line, to get the id for document (document_id). Thats just a basic reason that I see in my head for this not being viewed correctly, but still if I read the string from the 'file_for_str' function it's correct... I really hope that you could help me out to track this bug and fix it, or at least give me some ideas where could this bug come from.. I'll look into your example man, thank you for it and for your time as well, but I would like to try fixing my code first, cause I don't want to give up on it. friendly greets
|
|
|
Re: Three more questions
[Re: 3run]
#444922
08/21/14 22:12
08/21/14 22:12
|
Joined: Nov 2011
Posts: 274 de
lemming
Member
|
Member
Joined: Nov 2011
Posts: 274
de
|
1. 'file_for_str' reads .txt file line by line till delimiter 2. data which was read from the .txt file is sent into global pointers (vars, strings). (f.e. you see that 'document_page' in the .txt file, and I have same string in the code, this function will fill up the string with the text from .txt file automatically! this helps me to read such things like 'document title' or 'amount of max pages per document' for each document separately from one .txt file). Why do you write it to global vars/strings? If you want to "read unlimited amount of pages and documents from single .txt file" you'd need unlimited global vars. I think it's the wrong approach. Read them one by one and save them to a list or something. I just to read your code again and honestly I don't get it. I think it is indeed related to your approaches to read a file several times (though I don't exactly know how and why you actually do it) and recommend to start from scratch again and don't use global vars, but a global dynamic list.
|
|
|
Re: Three more questions
[Re: 3run]
#444934
08/22/14 16:17
08/22/14 16:17
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Maybe this is some kind of an engine limitation? Cause I've found out one very interesting thing... If I change 'document_page' to (let's say) 'doc_page' (which is shorter for 5 characters) this will make 5 more characters of the text visible.. So if before it was visible till 'hopeful' now it will be visible till 'hopefully th' so maybe 'var_for_name' can only read a limited amount of characters? Greets
|
|
|
Re: Three more questions
[Re: 3run]
#444935
08/22/14 16:32
08/22/14 16:32
|
Joined: Jul 2008
Posts: 2,107 Germany
rayp
X
|
X
Joined: Jul 2008
Posts: 2,107
Germany
|
I know, from other languages, theres a string limitation ... let me lie ... around 256 chars, not sure atm. Maybe the display, the text -> string is the problem? If this is bullshit, sry. But Manual says, "strings = no limits". mhhh. Dont know, never done this with lite-c. hope someone takes a look into.
greets
Acknex umgibt uns...zwischen Dir, mir, dem Stein dort... "Hey Griswold ... where u gonna put a tree that big ?" 1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected rayp.flags |= UNTOUCHABLE;
|
|
|
Re: Three more questions
[Re: rayp]
#444936
08/22/14 16:45
08/22/14 16:45
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
I know, from other languages, theres a string limitation ... let me lie ... around 256 chars, not sure atm. Maybe the display, the text -> string is the problem? If this is bullshit, sry. But Manual says, "strings = no limits". mhhh. Dont know, never done this with lite-c. hope someone takes a look into.
greets Problem is that 'var_for_name' can't read the whole text into the string (that's my guess).. Maybe I'll need to create an alternative for this thing... Greets
|
|
|
Re: Three more questions
[Re: 3run]
#444942
08/22/14 21:58
08/22/14 21:58
|
Joined: Nov 2011
Posts: 274 de
lemming
Member
|
Member
Joined: Nov 2011
Posts: 274
de
|
I've created three small functions to read text titles and pages So you now have like 8 or 10 functions to read text files to strings? 4 where already in your snippet where you read them to local strings, 1 or 2 you mentioned to read the global variables in a list (I still don't understand why you just don't skip that step) and another 3 for fixing reading the files? Well, at least it works. , but yet I have a small question. I create string pointers inside of this functions (f.e. STRING* textStr = str_cut), this strings are returned, but do I need to remove them at the end? Something tells me that I have to, You are not very clear here. Strings (plural intended?) are returned to what? Returned as return value? And you don't need to delete the string pointers as they are on the stack and get deleted when the function ends, but the strings they are pointing to. But I guess you or something meant that. and if so, what would be the best way to do that? Simple 'ptr_remove' - will be enough? Yes.
|
|
|
Re: Three more questions
[Re: lemming]
#444944
08/23/14 02:15
08/23/14 02:15
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
So you now have like 8 or 10 functions to read text files to strings? 4 where already in your snippet where you read them to local strings, 1 or 2 you mentioned to read the global variables in a list (I still don't understand why you just don't skip that step) and another 3 for fixing reading the files? Well, at least it works. well no, I have 8 functions for the whole thing (updating panels size /pos, reading titles and creating buttons, adding new documents, reading data and panel events) and only one of them runs in the main game loop, all others run once where they needed. And I don't see any problems here plus don't take the example which was posted above to serious, its just an example to show the problem (which has only ONE function that reads data from file, one handles loading process and two others could be even deleted particularly in this example, but I see no reason to care about them either). You are not very clear here. Strings (plural intended?) are returned to what? Returned as return value? And you don't need to delete the string pointers as they are on the stack and get deleted when the function ends, but the strings they are pointing to. But I guess you or something meant that. well by saying that they (strings) are returned, I mean that THEY are returned (return(string name)), you are making thing too complicated if I would return a value, I would say that they do return a value.. but anyway do I need to remove this string pointers (STRING*) which are created locally in the functions body? Greets
|
|
|
|