zasxes Posted June 11, 2004 Share Posted June 11, 2004 (edited) Ok I am having a problem with the function below. I need to check that a link exists on a web page and that it is the first link in the frame. Here is an example of what the link might look like: "http://serv/Validation/Meed/(pmb5eg45qkquutv3xzd)/Modules/EAH/PrimaryRecordPage.aspx?ID=0&S=110&msxc=21:6790]http://serv/Validation/Meed/(pmb5eg45qkquu...10&msxc=21:6790" Since the security code always changed I cannot just match it. So I need to cut it up in an array but if the link does not exists it errors out saying that the array is out of range. Any ideas Func RECORDPAGE() Dim $ADD_SUB[10] Dim $ADD[2] $j=0 While $j < 5 MOVETO($MAIN);A function that activates a frame and does some other stuff Send ("{TAB 3}");this tabs top the first link in the frame $ADD_LINK = StatusbarGetText($TITLE) $ADD_SUB = StringSplit($ADD_LINK, "/") $ADD = StringSplit($ADD_SUB[9], ".") If $ADD[1] = "PrimaryRecordPage" Then Exitloop $j=$j+1 Wend If $ADD[1] <> "PrimaryRecordPage" Then MsgBox(262144, "Error", "Error, you must be on the " & $ADD[1]) Exit Endif EndFunc;=>RECORDPAGE() Edited June 11, 2004 by zasxes Link to comment Share on other sites More sharing options...
pekster Posted June 12, 2004 Share Posted June 12, 2004 Why not test to make sure the array has 9 elements (or however many it has when you get the proper URL selected) ? Only attempt to access the 9th element if and when the proper number of elements exist. In the code snippet below, I have assumed that you are waiting unti the result of the stringsplit is excatally 9 seperate strings. Adjust it accordingly. My example code is designed to go above your $ADD = StringSplit($ADD_SUB[9], ".") line:If $ADD_SUB[0] = 9 Then ;test to make sure the proper elements are in the string $ADD = StringSplit($ADD_SUB[9], ".") Else ;do something to handle the case of an invalid selection EndIf [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now