6 Replies - 1438 Views - Last Post: 21 July 2009 - 10:22 AM

#1 giuseppe105   User is offline

  • D.I.C Regular

Reputation: 9
  • View blog
  • Posts: 448
  • Joined: 15-May 08

Simple Question

Posted 17 July 2009 - 02:27 PM

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 July 2009 - 02:28 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Simple Question

#2 wildgoose   User is offline

  • D.I.C Regular
  • member icon

Reputation: 67
  • View blog
  • Posts: 468
  • Joined: 29-June 09

Re: Simple Question

Posted 17 July 2009 - 04:58 PM

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!
Was This Post Helpful? 0
  • +
  • -

#3 giuseppe105   User is offline

  • D.I.C Regular

Reputation: 9
  • View blog
  • Posts: 448
  • Joined: 15-May 08

Re: Simple Question

Posted 17 July 2009 - 06:35 PM

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 July 2009 - 03:37 PM

Was This Post Helpful? 0
  • +
  • -

#4 Aeternalis   User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 291
  • Joined: 13-July 09

Re: Simple Question

Posted 20 July 2009 - 02:29 PM

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
Was This Post Helpful? 0
  • +
  • -

#5 giuseppe105   User is offline

  • D.I.C Regular

Reputation: 9
  • View blog
  • Posts: 448
  • Joined: 15-May 08

Re: Simple Question

Posted 20 July 2009 - 07:48 PM

I was trying to create an example. but it would have been better if i gave you the code. I'm sorry.
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.
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
Was This Post Helpful? 0
  • +
  • -

#6 masteryee   User is offline

  • D.I.C Regular

Reputation: 40
  • View blog
  • Posts: 271
  • Joined: 16-May 09

Re: Simple Question

Posted 21 July 2009 - 09:44 AM

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:

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.
Was This Post Helpful? 1
  • +
  • -

#7 giuseppe105   User is offline

  • D.I.C Regular

Reputation: 9
  • View blog
  • Posts: 448
  • Joined: 15-May 08

Re: Simple Question

Posted 21 July 2009 - 10:22 AM

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 July 2009 - 11:20 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1