Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need helping with searching

Status
Not open for further replies.

Statey603

Programmer
Nov 10, 2009
196
US
OK...I am new to PowerBuilder. I am trying to find references in the code/script to a specific button and am not sure the best way to go about this.

I have tried executing a Search by right-click on the top item in the tree in the left pane. The search returns a handful of results which is great.....but when I double click on a specific search result, it opens the window object but does not go to any specific line of code. The behavior is the same as if I had doub-clicked on the window object in the left pane to open it. There are many, many functions and event and I was hoping to zero in a little closer.

Am I doing something wrong?

Does anyone have any recommendations or ideas on how to search through code??

thanks
 
Yes this does happen...
I usually just look at the object.method listed in the search results and navigate manually to that specific script.

Matt

"Nature forges everything on the anvil of time
 
Can you please elaborate on object.method?

I am not quite sure how to identify.
Here are some examples of search results.

// the next line makes sense to me and I can get to it by double-clicking on it
xxxx_xxxx.pbw(w_window_name).wf_setup_buttons: cb_letters.ENABLED = FALSE

// these next 2 lines show up in the search, but I do now how to get to them. Is this in protected code?
xxxx_xxxx.pbw(w_window_name).w_window_name: this.cb_letters=create cb_letters
xxxx_xxxx.pbw(w_window_name).w_window_name: this.Control[iCurrent+3]=this.cb_letters

thanks

 
tip: once you get used to using powerbuilder, lots of times it results faster and easier to just use the 'edit source' option that comes up by using right mouse button on any object in the library painter. It shows you all the code without having to click on objects, select events etc. It's great for doing search and replace within the whole object or do minor changes. (You must be more carefull though.)

regards,
Miguel L.
 
about your question of 'protected code':
(repeating your statement):
---------------------------
"/ these next 2 lines show up in the search, but I do now how to get to them. Is this in protected code?
xxxx_xxxx.pbw(w_window_name).w_window_name: this.cb_letters=create cb_letters
xxxx_xxxx.pbw(w_window_name).w_window_name: this.Control[iCurrent+3]=this.cb_letters"

Once you use the 'edit source' it's not protected but I recommend strongly not to change it.
There's a section of creating and destroying all of the controls/objects inside of your object and that's what you found with your search.

When an object is created / window opens, the first thing that will execute is the creation of the controls. It's only good to change the order if you have bad programming and for example have code depending of things done in a constructor event of one of the controls. (It would be better to place that code in the open event (in case of a window), but I've seen it happen in older versions of PFC's in governomental tax office in Holland. (if you change the order of creation also change the order of destruction, but better ... don't touch them). Another thing you might find in exported code (or using the 'edit source' option) is binary code that you should never touch. (in case you use ocx in (for example) a window you can see this).

regards,
Miguel L.
 
Miguel.....

I like that. I was able to locate all of the found references very quickly in the Edit Source window.

Thanks
 
I do realize that I should not be making changes in the Edit Source view. I mainly like this so I can locate all of my Search results.

thanks again
 
Alright, don't worry You can make all the changes You want, but start with little/easy ones (like renaming variables), but just be carefull with the sections I told You. If anything is wrong, the compiler will give an error once you save anyway.

regards,
Miguel L.
 

OK....I am needing for more guidance.

I am trying to locate where in the code a button is being made visible. Initially on the window, the visible property is not checked.

When I use rmb Search for the text 'visible', I get the following list of Matches.

---------- Search: Searching Target options for 'invisible'
pfcapsrv.pbl(pfc_w_message)open.0098: // Make button(s) visible or invisible.
pfcapsrv.pbl(pfc_w_message)open.0132: // Make button(s) visible or invisible.
pfcapsrv.pbl(pfc_w_message)open.0167: // Make button(s) visible or invisible.
---------- Finished Searching Target options for 'invisible' (10:53:44 AM)

When I look in the code of one of the open events returned by the search, I see more references (6 to be precise) to the text 'visible'.
(code stub shown at bottom of this post)

Why weren't all 6 of these occurrences of 'visible' returned by the search?
FYI: I did NOT have Match Case enabled in the search.

How can I locate something like this if the search does not retunr all of the occurrences?
Am I doing somethign wrong here?

I guess I am looking for the most thorough way to perform a search.


code stub
....
If li_bmp > 0 Then
lv_bmp.X = lv_bmp.X - 30
llvi_item.PictureIndex = li_bmp
li_Index = lv_bmp.AddItem(llvi_item)
lv_bmp.SetItem(1, llvi_item)
llvi_item.ItemX = -100
llvi_item.ItemY = 5
Else
lv_bmp.Visible = False
End If

// As requested, Enable/Disable Print.
cb_print.enabled = inv_errorattrib.ib_print
cb_print.visible = inv_errorattrib.ib_print

// As requested, Enable/Disable User input.
cb_userinput.enabled = inv_errorattrib.ib_userinput
cb_userinput.visible = inv_errorattrib.ib_userinput

// As requested, set the timer.
If inv_errorattrib.ii_timeout > 0 Then
// Automatically close this response window after ii_timeout seconds.
timer(inv_errorattrib.ii_timeout)
End If

// As requested, display/enable the appropriate button(s).
Choose Case inv_errorattrib.ie_buttonstyle
Case ok!
//-- An (OK) button has been requested. --

// Set the text attribute(s).
cb_1.Text = "OK"

// Set the default attribute(s).
cb_1.Default = True
cb_1.SetFocus()

// Make button(s) visible or invisible.
cb_1.Visible = True
cb_2.Visible = False
cb_3.Visible = False
....
 
lets see. .. if you do a search with right mouse on top of your object (pfc_w_message, I suppose), then all occurences should be indicated.

Are you sure you'r not mixing up parent object with child object.?

sometime you have to to an explicit 'regenerate' of your object. ('optimize' you library too, sometimes there's 'lost code' in pbl's, especially after trying to import exported code that didn't compile well).

if you use the 'edit source' all references to 'visible' should be found, be sure to position the cursor at the beginning of the file.

HIHelps

regards,
Miguel L.
 
okay, our messages crossed...
good to see things are working out for you

regards,
Miguel L.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top