Normal Topic FormRunCustomProgram ( ) Question (Read 950 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
FormRunCustomProgram ( ) Question
Dec 19th, 2013 at 10:47pm
Print Post Print Post  
What I am trying to do is simply take the content that I typed in one of the element of the form and put that into one of the element of the other open form. For that I am using "Copy" command button. I have tried to use SetCopyBuffer ( ) and @GetSelectionContents() on form Reveal event, also tried to use FormRunProgram ( ). Both of them work but both of them - eventhough I have closed the first form, it takes me back to the form again one more time.  So I thought of using FormRunCustomProgram ( ).  As you can see from my note, I am unable to make it work using any variable for value and it will be difficult to use concrete value in the program. I will appreciate if someone find a way to have the command works with a variable.

Following is the code in Copy Command Button. Code is the element, the content of which I am trying to copy and place it in the other open form.
Code
Select All
var vCode as string
var vSecondPart as String


//SetCopyBuffer (Code)

//WriteLn(@GetSelectionContents()  )

//ClientLocalValue ("CopyImm", "Copied")
//ClientLocalValue ("SubjectRecNumber", RecNumber)

//ClientLocalValue ("RecommendedImm", Code )

vCode = Code


vSecondPart = "ImmR = 1000"   // works

//vSecondPart = "ImmR = " + vCode  //does not work



//vSecondPart = @Chr (34) + "ImmR = " + vCode + @chr (34)    //does not work

WriteLN (vSecondPart)

//FormRunCustomProgram("Physical", "ImmR = " + vCode )   //Does not work

//FormRunProgram ("Physical", "Imm_Record", PROGRAM_EVENT_LE_CHANGE )

FormRunCustomProgram("Physical", vSecondPart )

Clear (Code)

@Exit

 

  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: FormRunCustomProgram ( ) Question
Reply #1 - Dec 20th, 2013 at 2:29pm
Print Post Print Post  
Hello Bharat,

Are you just trying to set a field value on the other form? If so why not use FormFieldValue()?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: FormRunCustomProgram ( ) Question
Reply #2 - Dec 20th, 2013 at 2:53pm
Print Post Print Post  
Thanks for response.  Other form is open and not saved yet. It is in @add mode. Do not know for sure if other records are there in @add mode of that particular form that are already saved.  Just wondering if that would work? Also noted that FormRunCustomProgram ( ) would not work if the value in the program is not just numbers.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: FormRunCustomProgram ( ) Question
Reply #3 - Dec 20th, 2013 at 7:52pm
Print Post Print Post  
Using zero as record number, FormFieldValue ( ) worked fine for my requirement. Thank you Ray for your input and advice. I have so far used FormFieldValue ( ) with MainForm / Subform setup only. Thanks again.

I am still wondering about following:
1. Why FormRunCustomProgram ( ) does not work with variable and does not work with non-number value?
2. Why SetCopyBuffer ( ) and @GetSelectionContents() on form Reveal event goes back to the original form even after closing that form after taking focus of form where @GetSelectionContents() is executed?

3. The same as above with  FormRunProgram ( ).. Just wondering!

  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: FormRunCustomProgram ( ) Question
Reply #4 - Dec 20th, 2013 at 8:36pm
Print Post Print Post  
Hello Bharat,

1: It does work with a variable and with a text value but you have to be sure to write it correctly. Let's take the following code

Code
Select All
vCode = "TestCode"
vSecondPart = "ImmR = " + vCode  



When executed vSecondPart is going to equal
Quote:
ImmR = TestCode


If you were to copy that into the programming editor of your Physical form and test it, it would throw an error saying it doesn't know what TestCode is. The same is gonna hold true for FormRunCustomProgram() it can't compile as it doesn't know what TestCode is. However,

Quote:
ImmR = "TestCode"

Will compile, so that is what we need to generate. That means our code needs to be

Code
Select All
vCode = "TestCode"
vSecondPart = "ImmR = """ + vCode + """" 



The reason it is working with numbers is because Sesame knows what 1000 is.

as for #2 and #3, I would have to see the behavoir in person to determine why it is doing what it is doing. Once you start mixing On Form Reveal with commands that Open or Close other forms, or even switching to other forms there gets to be a lot going on.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: FormRunCustomProgram ( ) Question
Reply #5 - Dec 20th, 2013 at 10:09pm
Print Post Print Post  
Your vSecondPart code definitely works. However, it will take some time for my dense brain to understand! Thanks. Now I have a couple of different ways I can have this accomplished. Thanks again.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: FormRunCustomProgram ( ) Question
Reply #6 - Dec 21st, 2013 at 7:40am
Print Post Print Post  
Got it now! The following is a little simplified for my understanding and it worked fine so did the FormfieldValue ( ). Thanks.

Code
Select All
vSecondPart = "ImmR = " + @Chr (34) + vCode + @Chr (34)
 

  
Back to top
 
IP Logged