Easy way to: varA = VarA..varTABLE?

Discuss any general programming issues here
Post Reply
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Easy way to: varA = VarA..varTABLE?

Post by Bugala »

As i have now made this debugfile.txt system where i keep printing out what is happening during the execution of the program to help find bugs, I am now having another kind of problem.

In some cases function receives msg (buttons).

Since i want to know what variables i have been sending, I am using:

Code: Select all

ForEach(msg.userdata, 
                          Function(index, value)
                                           tempstring$ = tempstring$..index.." = "..value
                         EndFunction)
WriteString(1, tempstring$)         
Works fine otherwise, except, in some cases userdata might be containing tables inside its variables, and in that case program fails.

I have already made a workaround for it, but because this situation is in many different places of code, my solution isnt quite optional.

What I would like to happen is what happens with debugprint.

If i use debugprint(VarA.." / "..VarB)

Then if VarB is a table, debugprint prints out its address.

Is there any simple way to be able to fix my problem so that it would be putting that address instead? That is there for example some command where i can add to string some stuff in such way that it automatically understands to put tables addressess as part of that string instead of failing?

in style of for example:

Code: Select all

a = a + 1
or

Code: Select all

a = Add(a, 1)
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Easy way to: varA = VarA..varTABLE?

Post by airsoftsoftwair »

Just use ToString() and you're set.
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: Easy way to: varA = VarA..varTABLE?

Post by Bugala »

Great, that is exactly what i was wishing for.
Post Reply