Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Code to compare two VFP strings?
Message
From
25/01/2023 13:31:33
 
 
To
25/01/2023 13:21:50
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01685937
Message ID:
01685946
Views:
26
>>Hi,
>>
>>I think there was a discussion/question on how to compare two long strings. I simply missed it.
>>
>>I have 4 functions (in my VFP application) which seem to have a similar SQL Select. I need to compare them (two at a time) and refactor the application so that only one function would have this SQL Select. I prefer not to install any software on this PC. This is Windows 7 and I am afraid that a new software will break something (call me paranoid)
>>
>>Please let me know if this is possible with a VFP function.
>>
>>TIA
>
>
>So, IOW you have two strings, each contains a SQL command, somehow formatted and you like to figure out if they are even? It could be done, as long as similar excludes different order of fields and joins and expressions and so on. Anyway, comparing with self written fox code might be overkill for just 4 examples.
>
>If you have VFP, consider to install Thor, set up BeautifyX so that it will pretty format SQL SELECT (it will split the SQL into lines with leading keywords).
>Anyway, I recommend to break the SQL into lines as deep as possible. Compare this.
>
>If you fear to install anything on this very comp, isolate the strings to files and just use a decent computer. Any compare tool, UltraCompare (there is a free trial for what I know), BeyondCompare or a hundred other tools will do.
>Set up a throw-away git repo, commit the one, then the second one with same name, git will list the changes. This you can run from an USB thumb stick. https://github.com/git-for-windows/git/releases/download/v2.39.1.windows.1/PortableGit-2.39.1-32-bit.7z.exe
>Two windows side by side in VFP IDE might be enough if pretty formatted.
>Endless possibilities.
>
>If you really need to use VFP, I would splitt into lines anyway. BeautifyX is a good example how to do this, several thousand lines in a bunch of methods. Forget it. A SQL could be coded different and give 100% the same result.
>
>You need to compare line by line first, and on differences you need to figure out if they are the same anyway.
>SELECT FieldA FROM bla;
>SELECT FieldA FieldA FROM bla;
>SELECT FieldA AS FieldA FROM bla
>are the same, but how will you compare this with a machine? I mean, for a compare. ;)

Thank you for the detailed reply. The SQL Select in each PRG has about 10 lines. So, I will attempt to compare them, line by line. Then, a customer will test it (without knowing it :) I will use the expression of one of the US politicians "You never let a serious crisis go to waste." :)
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform