Forum Discussion

sfo_sc's avatar
sfo_sc
Contributor
15 years ago

JScript Type Mismatch

I wrote a piece of code that read in excel data and input the fields.  During the first loop, it is working correctly.  But once it get into the second loop, I got an error saying Type Mismatch.  Can someone tell me what's wrong with my script?



while(!States.EOF())


{


 


//Clicks the 'Add' button.


Aliases.mops.Main_Screen.Main_Win.Composite.GloPara_Win.GPara.GPara_Layout.GPara_TabFolder.TradingScheduleComposite.Transitions.LayoutComposite.LayoutComposite.Add.ClickButton();


Aliases.RefreshMappingInfo();


Aliases.mops.Main_Screen.Main_Win.Composite.GloPara_Win.GPara.GPara_Layout.GPara_TabFolder.TradingScheduleComposite.Transitions.LayoutComposite.Table.ClickItem(0, 0);


Aliases.mops.Main_Screen.Main_Win.Composite.GloPara_Win.GPara.GPara_Layout.GPara_TabFolder.TradingScheduleComposite.Transitions.LayoutComposite.Table.DateTime.wTime = States.Value(0);


 


Aliases.RefreshMappingInfo();


Aliases.mops.Main_Screen.Main_Win.Composite.GloPara_Win.GPara.GPara_Layout.GPara_TabFolder.TradingScheduleComposite.Transitions.LayoutComposite.Table.ClickItem(0, 1);


Aliases.mops.Main_Screen.Main_Win.Composite.GloPara_Win.GPara.GPara_Layout.GPara_TabFolder.TradingScheduleComposite.Transitions.LayoutComposite.Table.Text.SetText(States.Value(1));



............




 


States.Next();



 





}



Please see the attachment for the screen shot of the error message.

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    It's hard to tell what's wrong with the script.  From what I can tell everything looks good.  My guess is that, on your second row of data, the value in the Zero column of your States file is not a valid WTime value.  Could you post up your "states" file?
  • Hi,



    You are right, it is how the cell value type problem.  That actually bring up another question I have.  For value we want it to be int, do we need to change the cell properties to number and for string value, we need to change it to text value in excel cell?



    Thanks,

    SC
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    What you should do is use the various aqConvert methods to make sure that data that you are reading in from your spreadsheet matches what needs to be input into the field.  For example, aqConvert.VarToInt will attempt to convert whatever value you return as an integer.  aqConvert.VarToStr will attempt to convert the value to a string.