Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 533 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
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 Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: lemming
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:
Code:
// 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 frown
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:
Quote:
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


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Three more questions [Re: 3run] #444922
08/21/14 22:12
08/21/14 22:12
Joined: Nov 2011
Posts: 274
de
lemming Offline
Member
lemming  Offline
Member

Joined: Nov 2011
Posts: 274
de
Originally Posted By: 3run
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. frown 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: lemming] #444924
08/22/14 05:43
08/22/14 05:43
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
The thing is, that to check the ID and to read the string we don't need to use array and using global stuff for this is perfectly fine. Cause as soon as I read data (into global var or string), I save it into the array (in original code). I use list to save text's title, id, max page amount and each page (one by one), but I've ripped everything from this example to make it simplier. So it has nothing to do with the problem. Which part exactly you can't understand, I'll try to explain it more with some deeper details.

Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
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 Offline OP
Senior Expert
3run  Offline 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' grin so maybe 'var_for_name' can only read a limited amount of characters?

Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
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 Offline

X
rayp  Offline

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 Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: rayp
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... frown

Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Three more questions [Re: 3run] #444938
08/22/14 19:27
08/22/14 19:27
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Thanks God I've fixed this thing. I've created three small functions to read text titles and pages, 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, and if so, what would be the best way to do that? Simple 'ptr_remove' - will be enough?

Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Three more questions [Re: 3run] #444939
08/22/14 19:33
08/22/14 19:33
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
you can create it runtime like
str = str_create("#4000");
then you can check its real length by str_len(str);

unfortunately I don't know too much about texts I use only txt_for_dir and for file name string inputs... but I would use txt_create() where you can set the number of strings stored e.g. in a separate info file. that could help to avoid length problems, and can save some memory.


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: Three more questions [Re: 3run] #444942
08/22/14 21:58
08/22/14 21:58
Joined: Nov 2011
Posts: 274
de
lemming Offline
Member
lemming  Offline
Member

Joined: Nov 2011
Posts: 274
de
Originally Posted By: 3run
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.

Originally Posted By: 3run
, 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.

Originally Posted By: 3run
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 Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: lemming
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 wink 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).

Originally Posted By: lemming
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 grin 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


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Page 2 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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