VB/Cimbasic Code Suggestions

B

Thread Starter

Burda, Jason M.

Looking for a code snippet or similar for basic, visual basic, CimBasic or similar to do the following. I have an array 13x21 that I want to put in a data file or in the code and use a dialog box to take user input for the top most and left most row and return a value in the array. Example: XXXXXXXXX YZZZZZZZZZZ YZZZZZZZZZZ YZZZZZZZZZZ YZZZZZZZZZZ YZZZZZZZZZZ User enters a y and x value and routine return the corresponding Z value. I nothing else the logic would be useful. Thanks
 
Y

Yosef Feigenbaum

I am assuming that you are not interested in using Cimplicity points so we'll do this with variables. 1) Create a text object. Call it XVal (do this under the General Tab) 2) Create a variable for the object. Call it X. 3) Create an event (MouseUp) for the object. Create a new procedure and use the Variable Assign method. Select the Object XVal and the variable X. You can now do variable entry without having to use a point in Cimplicity. The value of the variable is available to you by accessing the variable from within the object's script. Assuming that the script will run from within the object (ie. as another action in the above defined procedure) you can access it like this: Dim MyX as Integer MyX = CimGetObject.GetVariable("X").Value You can now do whatever error checking you want on the variable. In order to display the value after looking it up you can either: Assign it to a variable as above (I am assuming that you are using another object) or you can assign it to the text of a text object as follows: CimGetScreen.Object.Objects.Item("TextDisplay").TextFormat.Text = Cstr(Value) (Assuming you have an object called TextDisplay on the screen.) Hope this gets you going Yosef (8{)} ( .)
 
B

Burda, Jason M.

Thanks for the info. However, since I probably wasn't specific to my questions. I am looking for a suggestion for logic or code structure to use an array or other method to look at the top row of a matrix and the left most column and based on the value of the top row and left column find the cooresponding value. Consider the example (my matrix will be much bigger) 1 2 3 5 6 6 7 6 3 2 1 5 3 4 5 I used a dialog box, the user enters 5 as the left most column value, and then 2 as the top row value, my code return a 6 as the look-up value. I understand fully how to set up the dialog box, and use screen variables, virtual points, etc. I am wondering what ways are there to do this, so far my two suggestions have been to make a nxm array and enter the data that way or put the data in a database table and do a query on the nth row and mth column (this requires SQL - which I know little or nothing about), the other option would be to store the data in a sep. file and make a call to the file (don't know how to do this either), Any suggestion appreciated. JB
 
Top