Page 1 of 1

Conversion to ADS ideas

Posted: Tue Sep 04, 2018 11:10 am
by rdonnay
I am helping a customer convert an application to Advantage Server. I have been through many of these conversion projects over the years but this one is giving me some difficulties that I have not encountered before.

In particular, the application uses databases of very long names (longer than 10 characters).

DBFCDX allowed aliases to be longer than 10 characters, but ADSDBE does not.

Obviously, I can open the database and assign an alias of 10 or less characters, but then a lot of code needs to be changed.

Example:

USE INSPECTIONAGGREGATE VIA (AdsSession()) ALIAS 'INSPECTION'

INSPECTIONAGGREGATE->(dbGoTop()) // this will now fail and must be changed.

This can affect hundreds of lines of code.
I'm trying to think of a strategy that would not require all those code changes.
The more that code is changed, the more likely of runtime errors.

Any ideas?

Re: Conversion to ADS ideas

Posted: Tue Sep 04, 2018 1:21 pm
by Auge_Ohr
hi,

what about

Code: Select all

#xtranslate LongName => ShortName

Code: Select all

USE INSPECTIONAGGREGATE VIA (AdsSession()) ALIAS 'INSPECTION'
INSPECTIONAGGREGATE->(dbGoTop()) 
isn't it

Code: Select all

INSPECTION->(dbGoTop())

Re: Conversion to ADS ideas

Posted: Tue Sep 04, 2018 1:47 pm
by rdonnay
I thought about that, but looking at their code, it would be difficult.

The problem is that they are not consistent in the case of the alias. Some are upper case, some are lower case, some are possibly even mixed case. Some are in quotes and passed to other functions.

Re: Conversion to ADS ideas

Posted: Tue Sep 04, 2018 4:36 pm
by Auge_Ohr
next try ... it is the line with USE

Code: Select all

LOCAL INSPECTIONAGGREGATE := NetUse("INSPECTIONAGGREGATE",AdsSession(),"INSPECTION")

FUNCTION NetUse(cDBF,cVIA,cAlias)
BEGIN SEQUENCE 
   USE (cDBF) VIA (cVIA) ALIAS (cAlias)
   IF NetErr()
   ...
      cAlias := ""
   ENDIF
RECOVER
   cAlias := ""
END SEQUENCE
RETURN cAlias
now

Code: Select all

INSPECTIONAGGREGATE->(dbGoTop())
should work like before ... if it is not Empty()

Re: Conversion to ADS ideas

Posted: Wed Sep 05, 2018 1:36 am
by Tom

Code: Select all

INSPECTIONAGGREGATE->(dbGoTop())
This fails if INSPECTIONAGGREGATE is a var. It must be:

Code: Select all

(INSPECTIONAGGREGATE)->(dbGoTop())
I doubt this can be done with an automatism.

Re: Conversion to ADS ideas

Posted: Wed Sep 05, 2018 1:59 am
by Piotr D
Roger,
here is an idea:
make three arrays:
- first with original names of databases
- second with temporary names
- third with new short names
Then make an program, which read all source (PRG). With every PRG first automatically change words from first array with words from second (temporary names) array, and than change word from second array with words (new names) from third array.

Regards,
Piotr

Re: Conversion to ADS ideas

Posted: Wed Sep 05, 2018 11:00 am
by Auge_Ohr
Tom wrote:This fails if INSPECTIONAGGREGATE is a var. It must be:

Code: Select all

(INSPECTIONAGGREGATE)->(dbGoTop())
you are right it must be a Macro.

never-less it is easy to load all Files into Editor and Search/Replace those ALIAS with &

Code: Select all

&cLongAliasName->( DbGotop() )
i prefer & so i can see it is a Macro

Re: Conversion to ADS ideas

Posted: Wed Sep 05, 2018 11:20 am
by rdonnay
Piotr -

I think your idea is the best idea.
I have actually done this on projects in the past.
I wrote an Xbase++ program that rewrote the source code to change function names.

I sent an email to Alaska Software to ask if it was possible to trap any alias errors with the error handler and then recover them. They said that it is probably not possible.