Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Creating a directory on the PC  (Read 10527 times)
Sally W.
Posts: 32


« on: February 24, 2010, 04:40:51 pm »

I would like to be able to create a directory on the PC so I can copy templates and data for mailmerge into it.  It will be far easier to do it from the code than by getting the folks managing the PCs to make sure the directory exists on every single PC, plus we can change it much more easily if we ever want.  The following test program shows the sorts of things I have tried, all to no avail.  Has anyone here done this?  If so, do you have a code fragment you can share, please?

(this is Genero 2.1 on Solaris, with the front-end running on Windows PCs)

Code
  1. main
  2.  
  3. define l_bool integer
  4. define l_string string
  5.  
  6. let l_string = "mkdir c:\\zz"
  7. display l_string
  8.  
  9. #    CALL ui.Interface.frontCall("standard", "execute", [l_string, 1], [l_bool])
  10.    CALL ui.Interface.frontCall("standard", "shellexec", [l_string], [l_bool])
  11.  
  12. #    call winshellexec(  l_string ) returning l_bool
  13.        if l_bool then
  14.                display "OK"
  15.        else
  16.                display "Failed"
  17.        end if
  18.    display l_bool
  19.  
  20. end main
.
Four Js
Posts: 115


« Reply #1 on: February 24, 2010, 05:33:22 pm »

Don"t forget that on windows mkdir is not an executable but a command of cmd.exe

(from my testing you even can't type "mkdir c:\zz" in windows "execute" box).

So you've first to run cmd.exe and then give the command, for instance:

let l_string = "cmd.exe /C \"mkdir c:\\zz\""

which can be called using shellexec.
Sally W.
Posts: 32


« Reply #2 on: February 24, 2010, 05:46:23 pm »

Bingo - that works!  And it works with FrontCall as well.

Many thanks.  Case closed.
Reuben B.
Four Js
Posts: 1116


« Reply #3 on: February 26, 2010, 12:44:44 am »

Pierre-Nicolas,

Is it potentially possible to take the library distributed with the Windows runner %FGLDIR%/lib/os.dll, place it in the %GDCDIR%/lib folder and call the same methods https://4js.com/techdocs/genero/fgl/devel/DocRoot/User/Ext_os_Path.html#METHODS via a front-end extension
https://4js.com/techdocs/genero/gdc/devel/DocRoot/User/FEExtensions.html

i.e

CALL ui.Interface.frontCall("os","mkdir",dirname, ok)

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
.
Four Js
Posts: 115


« Reply #4 on: February 26, 2010, 08:26:02 am »

Not directly ; if the DLL you would like to load is not a GDC specific DLL, you'll need to rite a wrapper around it.

I don't know if os.DLL has been built the same way as C-extensions or if it has its own interface, but explanation below is valid whatever interface has been chosen:

To load a DLL dynamically, a program (gdc.exe or fglrun.exe) needs to know the function definition. With GDC, all functions must be like:

int functionName(struct frontEndInterface & fx);

where fx is a structure allowing the DLL to read in parameter and push out parameters.

with the DVM, the interface is much more complex, based on Informix. you can see it in f2c/fglExt.h. Most of Informix types can be passed, and a lot of functions / macro as proposed too. GDC api is very simple: call the function, get string / int parameter, return in / string parameter.

So what you would need to do is to make something like (thinking loud, I would not bet this compile directly ;) ) :
Code
  1. int mkdir(struct frontEndInterface & fx){
  2.   QString dirname;
  3.   fx.popQStriing(&dirname);
  4.   if (loadDVMLib("os")) {
  5.     int ret = execDVMFunction("mkdir", dirname);
  6.     fx.pushInteger(ret, false);
  7.     return 1;
  8.  } else {
  9.    return 0;
  10.  }
  11. }
  12.  

and of couse loadDVMLib() and execDVMFunction() should be very similar to the code we have in the runtime.

While this is potentially doable, I would either try to make it with a bunch of shellexec calls, or with my own library:


Code
  1. int mkdir(struct frontEndInterface & fx) {
  2.   QString dirname;
  3.   fx.popQStriing(&dirname);
  4.   QDir d(m_currentPath);
  5.  
  6.   return d.mkdir(dirname);
  7. }
  8.  

Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines