How do i call a procedure

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: How do i call a procedure

Post by ROBROS »

BeGeS wrote: Mon Aug 21, 2017 5:42 pm
ROBROS wrote: Mon Aug 21, 2017 4:23 pm Thank you for the advice, creating a project by IDE and building the .exe will do this for me, right?

Robert
:)

Using IDE is a personal choice.

I'm too heterodox as programmer, so I do not even consider using IDE.

Bernardo
Bernardo, you got me wrong, I didn't mean to use IDE as Development Environment, but when I create a project, write my own code and all that stuff in the same folder, and then press run, I expect all the stuff in that folder is compiled and linked. I tried to use IDE to "write" an app, I simply gave up,

Robert
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: How do i call a procedure

Post by Rathinagiri »

Bernardo, you got me wrong, I didn't mean to use IDE as Development Environment, but when I create a project, write my own code and all that stuff in the same folder, and then press run, I expect all the stuff in that folder is compiled and linked.
IDE can be perfectly used for the purpose you have mentioned above. This is exactly what I am doing while developing a project. I don't use the Form Designer.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
BeGeS
Posts: 125
Joined: Fri Jul 14, 2017 10:45 am
DBs Used: DBF
Location: La Mancha, Spain

Re: How do i call a procedure

Post by BeGeS »

ROBROS wrote: Mon Aug 21, 2017 6:11 pm Bernardo, you got me wrong, I didn't mean to use IDE as Development Environment, but when I create a project, write my own code and all that stuff in the same folder, and then press run, I expect all the stuff in that folder is compiled and linked. I tried to use IDE to "write" an app, I simply gave up,
At no point has it been my intention to discourage you from using IDE.

I am not the one to judge its advantages or its disadvantages.

Simply that I like to be the lord of my code, in the sense that I will only know it well if I have given birth. Development may be slower, but only at first.

Just one of the first things I've done has been to modify the build.bat file provided by HMG: some small adaptations to leave it to my liking. :mrgreen:

(I "baptized" him as HMGC.bat, the letter C of compiler :roll: :oops: ).
I get by with a little help from my friends
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: How do i call a procedure

Post by ROBROS »

BeGeS wrote: Mon Aug 21, 2017 8:11 pm
ROBROS wrote: Mon Aug 21, 2017 6:11 pm Bernardo, you got me wrong, I didn't mean to use IDE as Development Environment, but when I create a project, write my own code and all that stuff in the same folder, and then press run, I expect all the stuff in that folder is compiled and linked. I tried to use IDE to "write" an app, I simply gave up,
At no point has it been my intention to discourage you from using IDE.

I am not the one to judge its advantages or its disadvantages.

Simply that I like to be the lord of my code, in the sense that I will only know it well if I have given birth. Development may be slower, but only at first.

Just one of the first things I've done has been to modify the build.bat file provided by HMG: some small adaptations to leave it to my liking. :mrgreen:

(I "baptized" him as HMGC.bat, the letter C of compiler :roll: :oops: ).
Bernardo, you have not discouraged me to use IDE, maybe I'm just too "simple minded" to use it, and though I am not using it, it is very helpful to have a look at it in the samples, and so thanks to Roberto Lopez for giving us such a tool.

Robert
User avatar
BeGeS
Posts: 125
Joined: Fri Jul 14, 2017 10:45 am
DBs Used: DBF
Location: La Mancha, Spain

Re: How do i call a procedure

Post by BeGeS »

ROBROS wrote: Mon Aug 21, 2017 8:24 pm Bernardo, you have not discouraged me to use IDE, maybe I'm just too "simple minded" to use it, and though I am not using it, it is very helpful to have a look at it in the samples, and so thanks to Roberto Lopez for giving us such a tool.
Completely agree with you.
For those of us who are learning, everything is very useful and everything can be taken advantage of.
And my thanks to Roberto López and my admiration for his work are enormous.

IDE or no IDE is like choosing between beach or mountain for vacation. I am from the beach, and if more crowded, better, but I know people who would not go even if they charged money. They prefer to rest in an isolated environment. Very good. :D
I get by with a little help from my friends
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: How do i call a procedure

Post by ROBROS »

Hello friends,

I was so glad to have back "my append from sdf". It works, but I have to save "sheet.xls" to "sheet.prn" and so on. Then I remembered that in my self-introduction Marek and Serge told me I could directly read from excel and write to dbf.

Serge sent this function:

Function ImportData
LOCAL oExcel, oWorksheet, i

IF ! MsgYesNo('Start to process?','Confirm')
return
endif

oExcel := CreateObject( "Excel.Application")
oExcel:Workbooks:Open( GetCurrentFolder()+"\newshop.xls" ) // here right name
oExcel:Visible := .t.
sele a
use shoptype
zap

for i = 4 to 7 // here
cTypeO=oExcel:WorkSheets(1):cells(i,2):value
cTypeN=oExcel:WorkSheets(1):cells(i,3):value
cCustCode=left(oExcel:WorkSheets(1):cells(i,4):value,6)
cCustName=subs(oExcel:WorkSheets(1):cells(i,4):value,8,50)
appe blank
repl typeo with cTypeO, typen with cTypeN, cust_code with cCustCode, cust_name with cCustName
next
close databases
Return


There is one problem I could not solve:

If "counter" i=NumberOfLastRow+1 then, though the records are appended to dbf-file, the program crashes at runtime.

Of course I could open excel-file outside the program press ctrl and end and could enter the NumberOfLastRow via textbox-control Seems not very professional.

In a german xbase-forum I found these 3 lines of code:

oExcel:Cells:Item(65536, nColumn).Select()
oExcel:Selection:End(xlUp):Select()
nLastRow:= oExcel:ActiveCell:Row()

and added them to Serge's function.

Compiling the first of these 3 lines I get a syntax-error.

I have no knowledge of VBA.

Who knows what went wrong?

Robert

EDIT: Maybe the crash can be avoided by errorhandling?
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: How do i call a procedure

Post by mol »

Maybe your excel sheet contains data other type than Character?

Try this change of reading cells:

Code: Select all

cTypeO=oExcel:WorkSheets(1):cells(i,2):Text
cTypeN=oExcel:WorkSheets(1):cells(i,3):Text
cCustCode=left(oExcel:WorkSheets(1):cells(i,4):Text,6)
cCustName=subs(oExcel:WorkSheets(1):cells(i,4):Text,8,50)
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: How do i call a procedure

Post by ROBROS »

Marek,

as I wrote, data are appended, so data type should not be the problem, (but when i >number of last row of excel sheet, I get a runtime error). but I will try your suggestion tomorrow at office. On my pc at home (Linux) no excel is available.

Thank you
Robert
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: How do i call a procedure

Post by KDJ »

ROBROS wrote: Mon Sep 04, 2017 6:53 pm ...
oExcel:Selection:End(xlUp):Select()
...
What is the value of xlUp ?
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: How do i call a procedure

Post by ROBROS »

KDJ wrote: Tue Sep 05, 2017 4:54 am
ROBROS wrote: Mon Sep 04, 2017 6:53 pm ...
oExcel:Selection:End(xlUp):Select()
...
What is the value of xlUp ?
I don't know, I just typed in the lines. As I wrote I have no knowledge of VBA.

Robert
Post Reply