Select to view content in your preferred language

VBS: Carry variable value between layer forms

781
3
Jump to solution
02-28-2013 03:47 AM
AaronAmbrose
Deactivated User
Hi all,

I am new here, and am fairly new to VBS scripting.
My situation:
I have a master layer feature which retrieves info surveyed on utility poles. The collection template required to collect all the information on a busy pole is staggering. I have been playing with different strategies for years now.
So, I am now creating a variation where - once you come to the different pole attachments, at the activation of a button on the main pole form, a new form from a different layer pops up to gather the values of that specific attachment.
The new attachment feature is placed smack dab over the main pole block - as a separate element.
Once all the survey is collected, all the poles shapes and their sub-component shapes are imported to CAD where I have created a set of routines to associate and develop the total product.

To link the parent pole feature with the child attachment feature, I am using a Unique ID created with the auto-increment feature.
The barrier I have right now, is trying to grab a value from the child feature/form and carry it back over to the parent pole script.
So far, I have it so that everything works: the pole script keeps running after I return back to the pole, but I don't know how to switch the script focus to the child feature to grab info.

I totally understand all the concepts of VBS - as I am a CAD lisp guru. But the language and methods are still foreign to me. So my problem may be something really simple such as not defining the object in the subform correctly). Or, it could be that I am trying to do something near impossible; don't really know.
I read about the 'Evaluate' method required to access values between layer scripts, and tried to apply it, but I had no luck.

If there is NO way to do this, I assume I can accomplish my goal by writing to (and reading from) an external cvs file, but that could end up being quite complicated given the different things I need to do. And again, something else I will have to learn the code for.
So, am I missing something easy here? I just need direction or a code example for the part where you switch focus to the new form and access one of its controls.

Thanks to whoever can help! 🙂

Aaron
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
AaronAmbrose
Deactivated User
Aaron,
I can't tell from your posting if you have two separate script files. Have you tried using a global variable
Application.UserProperties("Variablename") that you define in the first script? Set the value in the child form and you should be able to read it when the child attachment form closes.

In one script, I have defined:
Application.UserProperties("SRLayerName") = "SRLayerName"

In another script, I use that variable:
If LCaseCompare(Application.Map.SelectionLayer.Name, Application.UserProperties("SRLayerName")) Then
         g_ServiceReqTreatment = True
End If

This will also work if both forms are in one script-- just define the variable as global.

Is there a reason why you don't want to get the data from the record for the child feature? Can you query the child feature based on the ID?

Hope this helps.

Chris


I actually ended up Googling around a few hours after I posted this and stumbled onto this very method (Application.UserProperties("Variablename") ) of saving variable information and it worked perfectly. Solved a very crucial and valuable problem for me.
So thank you very much for the great response Chris!
This might be basic to the VBS vets but like I said, I'm new to it. Re: your second suggestion: Probably another basic. I have the query techniques licked from my CAD scripting experience, but I am still getting used to the way you access objects.

Thanks again Chris! You da man!

View solution in original post

0 Kudos
3 Replies
ChrisSeabrooke
Deactivated User
Aaron,
I can't tell from your posting if you have two separate script files. Have you tried using a global variable
Application.UserProperties("Variablename") that you define in the first script? Set the value in the child form and you should be able to read it when the child attachment form closes.

In one script, I have defined:
Application.UserProperties("SRLayerName") = "SRLayerName"

In another script, I use that variable:
If LCaseCompare(Application.Map.SelectionLayer.Name, Application.UserProperties("SRLayerName")) Then
         g_ServiceReqTreatment = True
End If

This will also work if both forms are in one script-- just define the variable as global.

Is there a reason why you don't want to get the data from the record for the child feature? Can you query the child feature based on the ID?

Hope this helps.

Chris
0 Kudos
AaronAmbrose
Deactivated User
Aaron,
I can't tell from your posting if you have two separate script files. Have you tried using a global variable
Application.UserProperties("Variablename") that you define in the first script? Set the value in the child form and you should be able to read it when the child attachment form closes.

In one script, I have defined:
Application.UserProperties("SRLayerName") = "SRLayerName"

In another script, I use that variable:
If LCaseCompare(Application.Map.SelectionLayer.Name, Application.UserProperties("SRLayerName")) Then
         g_ServiceReqTreatment = True
End If

This will also work if both forms are in one script-- just define the variable as global.

Is there a reason why you don't want to get the data from the record for the child feature? Can you query the child feature based on the ID?

Hope this helps.

Chris


I actually ended up Googling around a few hours after I posted this and stumbled onto this very method (Application.UserProperties("Variablename") ) of saving variable information and it worked perfectly. Solved a very crucial and valuable problem for me.
So thank you very much for the great response Chris!
This might be basic to the VBS vets but like I said, I'm new to it. Re: your second suggestion: Probably another basic. I have the query techniques licked from my CAD scripting experience, but I am still getting used to the way you access objects.

Thanks again Chris! You da man!
0 Kudos
AaronAmbrose
Deactivated User
OK, now you are really gonna see how new I am to this forum; I can't - for the life of me - find where you click the green icon to indicate that this question is solved. How annoying!
0 Kudos