School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,102 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,020 people online right now. Registration is fast and FREE... Join Now!




Simple Question

 

Simple Question

giuseppe105

17 Jul, 2009 - 01:27 PM
Post #1

D.I.C Head
**

Joined: 15 May, 2008
Posts: 143



Thanked: 1 times
My Contributions
I have a file that reads a string. Can i take the contence of that string and use it in the code.
For example
StringMyName = "Giuseppe"

and then later in the code

i use the value of StringMyName directly in the code.

you cant do Create.cls(StringMyName) it needs to be the value "Giuseppe"

so instead of it saying Create.cls(StringMyName) it will say
Create.cls(Giuseppe)

This post has been edited by giuseppe105: 17 Jul, 2009 - 01:28 PM

User is offlineProfile CardPM
+Quote Post


wildgoose

RE: Simple Question

17 Jul, 2009 - 03:58 PM
Post #2

D.I.C Regular
Group Icon

Joined: 29 Jun, 2009
Posts: 429



Thanked: 55 times
Dream Kudos: 25
Expert In: Assembly,C,C++

My Contributions
I'm not sure what language you're trying to do this in, nor clear of what you're asking.

You can read in ASCII data from a file, put it into buffers and perform operations on those buffers. You can even manipulate the ASCII data and write it back out to a language file, that gets included by a program as part of its compile. There are a multitude for uses for strings!

User is offlineProfile CardPM
+Quote Post

giuseppe105

RE: Simple Question

17 Jul, 2009 - 05:35 PM
Post #3

D.I.C Head
**

Joined: 15 May, 2008
Posts: 143



Thanked: 1 times
My Contributions
I'm using vb6 I need to take the information in the text file and make it in the code. I don't think its possible since you compile the code into cpu instructions and what I'm asking requires me to change the code on run time.
Do you know where i can find methods of loading maps Using GDI32. It's ether a different method or i have an if statement for every graphic.

I was just walking around and thinking. Since I'm using GDI it stores the graphics in ram and has a value of the location in ram(i think) I could possibly Edit the map file and change the graphic name to the ram value and when i read the file i read a long instead of a string and i just might work. Now the only problem is... How to edit the map file and how to return it to normal when I'm done with it.

This wont work... because i have to use an if statement for each graphic still i guess im gona have to use a huge if statement no matter what.

This post has been edited by giuseppe105: 18 Jul, 2009 - 02:37 PM
User is offlineProfile CardPM
+Quote Post

Aeternalis

RE: Simple Question

20 Jul, 2009 - 01:29 PM
Post #4

D.I.C Regular
***

Joined: 13 Jul, 2009
Posts: 273



Thanked: 25 times
My Contributions
Why cant you do

Create.cls(StringMyName)

??
If you explain that it might help us understand your problem. You haven't really gotten any answers because the question is unclear.

Aet
User is offlineProfile CardPM
+Quote Post

giuseppe105

RE: Simple Question

20 Jul, 2009 - 06:48 PM
Post #5

D.I.C Head
**

Joined: 15 May, 2008
Posts: 143



Thanked: 1 times
My Contributions
I was trying to create an example. but it would have been better if i gave you the code. I'm sorry.
CODE

For i = 1 To 300
     Input #1, heder1, heder2, heder3
           If heder1 = "myWall" Then
                Call DrawGraphic(myWall, heder2, heder3)
           ElseIf heder1 = "myFloor" Then
                Call DrawGraphic(myFloor, heder2, heder3)
           End If
Next i
Close 1


The above code is what i have rite now and i need to make an if statement for every graphic.
If i change the code to.
CODE

For i = 1 To 300
     Input #1, heder1, heder2, heder3
          Call DrawGraphic(heder1, heder2, heder3)
Next i
Close 1

It Inputs the name of the image from the file. I need it to input the value of the location in ram of the image name.

I have a variable names myWall and its a long. that variable holds the DC of the image file. The DC is the location in ram. I don't know how to make the value of myWall that's in the file to tell the program to use the myWall variable.

If posting the program I have will help with finding a solution please tell me and i will attach.

This application is baced off a tutorial on GDI32
User is offlineProfile CardPM
+Quote Post

masteryee

RE: Simple Question

21 Jul, 2009 - 08:44 AM
Post #6

D.I.C Regular
***

Joined: 16 May, 2009
Posts: 269



Thanked: 38 times
My Contributions
Look into the Collection object, which acts as a hash table that allows you to store key/value pairs. You can map your possible "heder1" names to their corresponding long values. The first parameter of the Add method is the value, and the second parameter is the key, so assuming you stored your long values in similarly named variables:

vb6

Dim myCollection As New Collection
...
myCollection.Add myWall, "myWall"
myCollection.Add myFloor, "myFloor"
...
Call DrawGraphic(myCollection(heder1), heder2, heder3)


You may or may not need to cast "myCollection(heder1)" to a long type. If this doesn't compile, then do a search on google for a more complete example.
User is offlineProfile CardPM
+Quote Post

giuseppe105

RE: Simple Question

21 Jul, 2009 - 09:22 AM
Post #7

D.I.C Head
**

Joined: 15 May, 2008
Posts: 143



Thanked: 1 times
My Contributions
Thank you very much i will look into this and get back to you very shortly.
I added the code you told me and it just dose not draw the graphics. but i get no errors.

Never mind Thank you so much this solves one of my most horrible programing habits.

I was adding myWall and myFloor to the collection before i assigned values to the myFloor and myWall variables.
It works now, I can now start working adding transparency. And maybe i can switch over to the directX7 engine i wanted to use before but ran into the same problem.

This post has been edited by giuseppe105: 21 Jul, 2009 - 10:20 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 12:21PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month