how can i find defined variables "var_1,var_2... ->

Just starting out? Need help? Post your questions and find answers here.
j0sh
New User
New User
Posts: 3
Joined: Thu Aug 14, 2003 10:17 pm
Location: switzerland
Contact:

how can i find defined variables "var_1,var_2... ->

Post by j0sh »

hello.

how can i find all the variables that are set on "1" as content with the root name "var_" and then a number?

var_1, var_2, var_3,var_4...var_100...var_XXX

thx for help! :)

j0sh
www.josh.ch - webWare for you
- phpMyWebmin, a browser based file management tool for your server
- Admin's Control Panel, a template-like webSite content managing system

gr33tz & have fun! :) j0sh :)
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

I don't know what you mean...
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: how can i find defined variables "var_1,var_2... -&

Post by PB »

I don't understand either, but do you mean something like this?

Code: Select all

Dim var(100) ; Create an array of 100 variables.
For r=1 To 100 : var(r)=Random(1) : Next ; Fill them with 0 or 1 at random.
For r=1 To 100
  If var(r)=1 : Debug "Var("+Str(r)+") = 1" : EndIf ; Only show the vars set to 1.
Next
j0sh
New User
New User
Posts: 3
Joined: Thu Aug 14, 2003 10:17 pm
Location: switzerland
Contact:

Post by j0sh »

this sounds good. i'll take a look at it.

thx! :)
www.josh.ch - webWare for you
- phpMyWebmin, a browser based file management tool for your server
- Admin's Control Panel, a template-like webSite content managing system

gr33tz & have fun! :) j0sh :)
oldefoxx
Enthusiast
Enthusiast
Posts: 532
Joined: Fri Jul 25, 2003 11:24 pm

Variable Names are not Real

Post by oldefoxx »

The compiler associates named variables with a type and with references
to the memory address where the variable actually resides after it is
created (a process of assigning a value to it). But in the finished code,
all references are merely to the memory location itself. The type is used
to determine how many consecutive bytes of memory are involved.

In other words, the terms for variables names only have reference in the source code, and to the compiler during the compilation process, and to the debugger when it is enabled. If you try to "generate" variable names in your program, that is an activity that occurs after the fact - it happens after the program is compliled and being run, not prior to the compilation process where such efforts might be meaningful.

You can create variable names and stick them in an Include file, or use them to modify a PB source file - but to what end? The advantage of naming variables is that they can be made meaningful - X, Y, and Z might represtent the corrdinates in 3D graphics, and T might be used to represent a timeline. Renaming these to VAR_1, VAR_2, VAR_3, and VAR_4 will obscure any contexture meaning within the source code, which would certainly hinder you as the programmer, but gives you no added security in the final code, since those terms do not exist there in any form.

The only instance I can visuallize where obscuring the code generated as much as possible would be if you were trying to protect your code from being ripped off. It is remarkable how many inexperienced programmers consider this a primary concern, and how many more experienced programmers give away code without charge or compensation. The difference is largely because more experienced programmers have learned two essential things: (1) their greatest progress came as a result of being able to study other code as a learning tool, and (2) they have so much to learn, and to accomplish, that they come to realize that they have much less to protect and to fear than they once thought.

I might dream of writing the ultimate Artificial Intelligence Engine to drive a whole new breed of smart games, but that does not mean that I ever will, or that I even have the ability to understand and accomplish this if I had a lifetime of dedicated study left in me. And it is not without reason that most game programmers tend to be young, have few commitments on them, can slave away at a keyboard for 17 to 20 hours a day, and are motivated as much by a need to prove themselves as they are of ever making any money from their efforts.

There are some cruddy games offered FOR SALE, and there are some terrific games out there that are free for the taking. Some games are complete except for detailed instructions on how to play, an extensive help file, a proper effort to polish it up and package it, and a good marketing outlet. How many people find that they enjoy the programming, but just lose interest when the fun runs out and it is a tough sell to get the finished product in front of the buyers? In a live and learn mode, some programmers just give their efforts away, and move on to more serious opportunities.

Not that game programming isn't serious. In fact, for many reasons, it is about the most serious effort out there. But the competition is fierce, and the player is fickle, and it is like betting on the races - you may believe you are riding a winner, but it depends upon the field you are running against.
has-been wanna-be (You may not agree with what I say, but it will make you think).
Post Reply