• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Critical Error through StringCase function

Status
Not open for further replies.
Level 7
Joined
Jan 30, 2011
Messages
267
JASS:
scope test
    globals
        private constant string capitals = "ZYXWVUTSRQPONMLKJIHGFEDCBA"
        private constant string lowercase = StringCase(capitals, false)
    endglobals
endscope

why does this cause a critical error on loading screen? (it doesnt happen when i remove the StringCase call)
 
Level 7
Joined
Jan 30, 2011
Messages
267
you can

JASS:
    globals
        private constant string numbers = "9876543210"
        private constant string capitals = "ZYXWVUTSRQPONMLKJIHGFEDCBA"
        private constant string lowercase ="zyxwvutsrqponmlkjihgfedcba"
        private constant string database = numbers + capitals + lowercase
        private constant integer length = StringLength(database)
    endglobals

works without problems
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
some functions(most actually) fucks up when globals are loaded, for instance if you have global rect and you set it to WorldBounds, first time the map will most likely load with no problem, second time(restart map) it will pop error when map is loading
another example is CreateDialog, this also crashes the map when loading
I recommend only using CreateTrigger, CreateTimer, InitHashtable
Even I2S() will crash the load(at least it did for me)
do it like this:
JASS:
scope test
    globals
        private constant string capitals = "ZYXWVUTSRQPONMLKJIHGFEDCBA"
        private string lowercase = null
    endglobals
    private module m
        static method onInit takes nothing returns nothing
            set lowercase = StringCase(capitals, false)
        endmethod
    endmodule
    private struct init extends array
        implement m
    endstruct
endscope

Use this if you are using Vexorians JassHelper, if you are using Cohadars, then do:
JASS:
scope test initializer init
    globals
        private constant string capitals = "ZYXWVUTSRQPONMLKJIHGFEDCBA"
        private string lowercase = StringCase(capitals, false)
    endglobals
    private function init takes nothing returns nothing
        set lowercase = StringCase(capitals, false)
    endfunction
endscope

Disadvantage is, lowercase is no longer constant
 
Status
Not open for further replies.
Top