Micro Focus QTP (UFT) Forums
Help on arrays - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Help on arrays (/Thread-Help-on-arrays)



Help on arrays - AutomationTester2011 - 07-05-2011

Code:
Dim work(2)
work(0) = "Mon"
work(1) = "Tue"
work(2) = "Wed"
Erase work
ReDim work(5)
work(3) = "Fri"
PRINT work(4)

i have executed the above script and it is throwing error..i'm not sure why it is giving error..Can anyone correct the script

Thank you


RE: Help on arrays - rajpes - 07-05-2011

You should Redim at the time of array declaration as well
Code:
[b]ReDim[/b] work(2)
work(0) = "Mon"
work(1) = "Tue"
work(2) = "Wed"
Erase work
ReDim work(5)
work(3) = "Fri"
PRINT work(4)



RE: Help on arrays - AutomationTester2011 - 07-05-2011

Thanks for ur reply

but i'm declaring it as a static array and however would like to change the size of the array(dynamically)

Is it possible to change the static array into dynamic array

for ex:

Dim customer(30)
ReDim customer(50)

Is this correct?


RE: Help on arrays - rajpes - 07-05-2011

no not possible
but you could declare array in different way

Code:
work=array("mon","tue","wed")

redim preserve  work(5)

work(3)="thu"