Hi. I have several reasonably large projects. I am into good code re-use and leverage libraries - a lot. However, over time, libraries are re-factored or re-structured. Existing functions are often improved sometimes requiring changes in parameters and even return values.
This change creates a problem - the calling code needs updating. One solution is to use stubs which maintains the original API for the app, and translates the call to the new API. But that is messy, and the calling code does not benefit from the new capabilities of the API. Finding all occurrences of the original ‘calling’ code to change the call is the first need, and potentially replace the existing code with new code, is what is needed.
In the context of SC, how do you find all uses (calls) of a library function across all the code in a project (the first need)? And is it then possible to replace the code with other text? In other words, I am looking for the typical text editor find/replace functionality that has been in code editors since the 1980s - but I can’t find it in SC.
It seems that neither the project reporting or the ‘show diagram’ functionality report on library dependencies, so no help there.
Today, I have to work my way laboriously through every app where a call may be made, checking the code behind every event and every button. It is tedious, very time consuming and as you’d expect error prone - I miss stuff!
Surely there is a better way? Am I missing something? Any ideas?
Partial Solution:
FWIW, I have created a bash script (MacOS) that searches through the files in the Apps directory looking for use of a function. It returns a list of the app?s ?Friendly URL? and the count of times the function was used.
Usage: ./findfn <library_function_name> <project name>
Example command line: ./findfn ‘ld_text_get(’ OntraxWBC
Example Output: [INDENT]Looking for ld_text_get( in Scriptcase project OntraxWBC…
form-comms 5
form-comms-type 5
form-contact-account-expires 4
form-distrib-list 5
form-membership 3
form-newmem-comms 4
form-newmem-contact 2
form-newmem-document 2[/INDENT]
…
Bash script code (apologies for poor formatting - can’t get indents working): [INDENT]#!/bin/bash
if [ “$#” -lt “2” ]
then
echo “Arguments missing.”
echo “Usage: findfn <text> <project>”
else
echo “Looking for $1 in Scriptcase project $2…”
grep -c -H -R --exclude-dir=_lib $1 /Applications/Scriptcase/v9/wwwroot/scriptcase/app/$2 | awk -F’[/:]’ ‘{ print $9 " " $11}’ | awk ‘$2 > 0’ | sort | uniq
fi[/INDENT]
Issue: Just noting that there is an issue with the above - if you include calls to the function you are searching for in your internal library, the search count includes the occurrences in the library. You need to allow for that when reviewing the results.