how to initialize an array

Posted on 2005-04-06
Last Modified: 2008-02-26
hi experts,

i am maintaining an existing report and it has a formula with the ff code:

stringvar array FirstArray :=  ["", "", "", "", "", "", "", "", "", ""]

and it is doing it for an array with size 300.  the size has been increased now.  is there a way to change the code so that i can just specify the number, for example:

stringvar array FirstArray :=  [1000]

the above code is not working and i can't find anything over the net.  just thought that someone here might have an idea on how it can be done.


Question by:wala_lang
    LVL 100

    Expert Comment

    In looking through CR7 help, I don't find any way to declare an array except as you are doing it.

    >> is there a way to change the code so that i can just specify the number, for example:
    stringvar array FirstArray :=  [1000]

    Are you trying to declare an array of 1000 elements?  You may be able to use something like

    stringvar array FirstArray [1 to 1000] := " ";


    Author Comment

    yes, its 1000 elements.  i'm gonna give it a try.

    Author Comment

    i change the code of my formula to this:

    stringvar array FirstArray[1 to 1000] := "";
    numbervar counter:=0  

    and i'm getting the error message:

    The remaining text does not appear to be part of the formula on the last line.

    LVL 19

    Accepted Solution

    stringvar array FirstArray;
    Redim FirstArray [1000];

    The Redim function can be used to set the number of elements in the array. It can also be used to change the number of elements in an array at any time, but this must be done with care. Redim when used by itself will always create an empty array. This means you will lose stored items when you change the size of an array. If you need to Redim an array and maintain the existing valuies, then you use the operator "Redim Preserve" instead. This will resize the array, but keep the exsting values.

    Redim Preserve FirstArray [1000]

    you should also be aware that 1000 is the maximum number of values an array can hold.

    Hope this helps


    Author Comment

    it worked!  thanks gary.

    LVL 19

    Expert Comment

    Glad I could help


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
    There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now