Skyrimfus

Global variable inside function

5 posts in this topic

Hello.
Could you help me solve this problem

 

Global $NumberA = 10
Global $NumberB = 20


..... My code here

Call(_MyFunc1)

..... More code here

Func _MyFunc1()

$a = $NumberA + $numberB
Msgbox(0,"Output",$a)


EndFunc

;END OF CODE

But i get an error $NumberA and $NumberB is not defined

Share this post


Link to post
Share on other sites



@Jos Well you're right.
I've made a longs script and it was a mess, so today i decided to re-write it to be more readable in future use

Yesterday I had a problem Undefined variable, but today when i re-writed the code i didn't even run it, instead i came here and asked for help. Weird, now it works.

Well thanks for your help!

Share this post


Link to post
Share on other sites

#4 ·  Posted

Hi

I know its necro, but i don't want to start a new topic.

Global $i
function1()
func function1()
    for $i = 1 to 3
        function2()
    Next
EndFunc
Func function2()
    MsgBox(0,"i",$i)
EndFunc

If i run this script Msgbox shows me that $i is empty. It can't pass the value even if it's Global?

Thx for answer

Share this post


Link to post
Share on other sites

#5 ·  Posted

As per the help file:

Quote

For <variable> = <start> To <stop> [Step <stepval>]
statements
...
Next

The variable will be created automatically with Local scope

 

1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now