forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Solved] folder name as variable

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Pihas



Joined: 25 Oct 2008
Posts: 60
Location: Lithuania

PostPosted: Wed Jul 01, 2009 2:11 am    Post subject: [Solved] folder name as variable Reply with quote

How corectly to do it ? I can't find out :/
(C programing language + oslib)
----------------------------------------------

int folder_name_variable;

folder_name_variable = Brew;

Picture = oslLoadImageFile("Root/..folder_name_variable../test.png", OSL_IN_RAM, OSL_PF_5551);
_________________

Cooming Soon


Last edited by Pihas on Wed Jul 01, 2009 5:13 am; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
m0skit0



Joined: 02 Jun 2009
Posts: 226

PostPosted: Wed Jul 01, 2009 2:29 am    Post subject: Reply with quote

Better learn to program C first...
_________________
The Incredible Bill Gates wrote:
The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers.
Back to top
View user's profile Send private message
Producted



Joined: 04 Jun 2009
Posts: 56

PostPosted: Wed Jul 01, 2009 2:59 am    Post subject: Reply with quote

^That.
One of the first things you should learn is; what variables are and what they can do.

http://en.wikipedia.org/wiki/C_variable_types_and_declarations
This might help.
_________________
Producted.net
Back to top
View user's profile Send private message
Pihas



Joined: 25 Oct 2008
Posts: 60
Location: Lithuania

PostPosted: Wed Jul 01, 2009 3:10 am    Post subject: Reply with quote

I am asking just to write one simple situacion and you bring me link to wiki and advise to learn C.... Is it so hard?...
_________________

Cooming Soon
Back to top
View user's profile Send private message Visit poster's website
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Wed Jul 01, 2009 3:15 am    Post subject: Reply with quote

theres alot you need to learn but here

create a temporary collection or chars and use sprintf or snprintf look them up a good place is cpprefrence.com and cprogramming.com
Back to top
View user's profile Send private message MSN Messenger
svxs



Joined: 19 Jun 2009
Posts: 15

PostPosted: Wed Jul 01, 2009 4:03 am    Post subject: Reply with quote

Quote:
int folder_name_variable;

folder_name_variable = Brew;

Picture = oslLoadImageFile("Root/..folder_name_variable../test.png", OSL_IN_RAM, OSL_PF_5551);


It's tough to see what you're trying to do. Is folder_name_variable really an integer, or should it be a string? What is the type of Brew?

The most confusing thing is whether or not you want the _name_ of the variable as a token in your string, or if you want the _contents_ of the variable in the string. In the former case, you're not going to be able to pull that off without some mightily obscure extension to your compiler unless you want to keep track of it somewhere else by yourself.

But even then, it doesn't make sense. How would you address the name of the variable? You'd logically need to know its name in advance anyway. I imagine the obscurity of it is a mitigating factor in ISO 9899's decision to not support that. :)

In the ladder case where you'd want the contents of the variable to show up in your string, you could use sprintf() to write a formatted string to a buffer and use that.
Back to top
View user's profile Send private message
m0skit0



Joined: 02 Jun 2009
Posts: 226

PostPosted: Wed Jul 01, 2009 5:05 am    Post subject: Reply with quote

I think he's trying to do something like this:

Code:
char* strfolder_path = "Brew";
/* No more than 80 characters in path */
char* strpath[80] = "Root/";

strcat(strpath, strfolder_path);
strcat(strpath, "/test.png");

Picture = oslLoadImageFile(strpath, OSL_IN_RAM, OSL_PF_5551);

Maybe... :/
_________________
The Incredible Bill Gates wrote:
The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers.


Last edited by m0skit0 on Wed Jul 01, 2009 5:09 am; edited 1 time in total
Back to top
View user's profile Send private message
Pihas



Joined: 25 Oct 2008
Posts: 60
Location: Lithuania

PostPosted: Wed Jul 01, 2009 5:09 am    Post subject: Reply with quote

Thx m0skit0 that was exactly what i wanted to do . You saved my life time :-)

svxs, i am learnign programing by self and i don't know a lot things, even basics. I know other languages like PHP, LUA but have diferent sintax then C :/
_________________

Cooming Soon
Back to top
View user's profile Send private message Visit poster's website
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Wed Jul 01, 2009 7:09 am    Post subject: Reply with quote

You're making things harder on yourself by trying to learn both the PSP and C at the same time. We recommend people learn C, THEN move on to programming the PSP. It's easier, and means less basic questions here. We don't teach C, so if your question is C related, you're more likely to get razzed than to get an answer.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group