# Reading global var as string when it should be Number

**URL:** <https://forum.kirupa.com/t/reading-global-var-as-string-when-it-should-be-number/206798>\
**Category:** Uncategorized\
**Created:** [November 11, 2006, 3:01pm UTC](https://forum.kirupa.com/t/reading-global-var-as-string-when-it-should-be-number/206798 "2006-11-11T15:01:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul\_ferrie](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@paul\_ferrie](https://forum.kirupa.com/u/paul_ferrie)\
**Post date:** [November 11, 2006, 3:01pm UTC](https://forum.kirupa.com/t/reading-global-var-as-string-when-it-should-be-number/206798/1 "2006-11-11T15:01:12Z")

</div>

Hi guys,  
Trying to get myself upto speed with AS2  
I have a little script that checks “user access level” on my site

[LEFT][FONT=Courier New][/FONT][/LEFT]  
[FONT=Courier New]trace[COLOR=#000000]([/COLOR][COLOR=#ff0000]“USER LEVEL=”[/COLOR] + [COLOR=#000000] **\_global** [/COLOR].[COLOR=#000080]userLevel[/COLOR][COLOR=#000000])[/COLOR];[/FONT]  
[LEFT][FONT=Courier New]trace[COLOR=#000000]([/COLOR][COLOR=#ff0000]“type of=”[/COLOR] + [COLOR=#0000ff]typeof[/COLOR] COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR];[/FONT]  
[FONT=Courier New][COLOR=#808080]_//typeof returns string\</p\>_[/COLOR][/FONT]  
[FONT=Courier New][COLOR=#808080]_//string does not work for the if statement_[/COLOR][/FONT]  
[FONT=Courier New]if [COLOR=#000000]([/COLOR][COLOR=#000000] **\_global** [/COLOR].[COLOR=#000080]userLevel[/COLOR] != [COLOR=#ff0000]“5”[/COLOR] || [COLOR=#000000] **\_global** [/COLOR].[COLOR=#000080]userLevel[/COLOR] == [COLOR=#ff0000]""[/COLOR] || [COLOR=#000000] **\_global** [/COLOR].[COLOR=#000080]userLevel[/COLOR] == [COLOR=#0000ff]undefined[/COLOR][COLOR=#000000])[/COLOR] {[/FONT]  
[FONT=Courier New] adm.[COLOR=#0000ff]\_visible[/COLOR] = [COLOR=#000000] **false** [/COLOR];[/FONT]  
[FONT=Courier New][COLOR=#000000]}[/COLOR][/FONT]  
[/LEFT]  
UserLevel is set when the user logs in

ActionScript Code:  
[LEFT][FONT=Courier New]var userLevel:[COLOR=#0000ff]Number[/COLOR] = loadedUserData.[COLOR=#000080]userLevel[/COLOR];[/FONT]  
[FONT=Courier New]\_global.[COLOR=#000080]userLevel[/COLOR] = userLevel;[/FONT]  
[/LEFT]

What do i need to do to set \_global.userLevel as a number?  
Thanks  
Paul
