CoCreate User Forum

CoCreate User Forum (https://www.cocreateusers.org/forum/index.php)
-   CoCreate Drafting (https://www.cocreateusers.org/forum/forumdisplay.php?f=8)
-   -   load file defined (https://www.cocreateusers.org/forum/showthread.php?t=8227)

andrea 11-17-2015 01:33 AM

load file defined
 
how can I build a macro that loading if I do not find a file (with a specific name) , I load a default ???

Friedly 11-17-2015 11:16 AM

Re: load file defined
 
1 Attachment(s)
Hello Andrea,
have a look at this.

Code:

{ rem input in drafting the macro
Macrostart: 
v macro      v Parameter
file_exists "path/filename"

Global variable:  gv_file_existent
end rem }

DEFINE file_exists
  PARAMETER File_1
  LOCAL Default_file
  LET Default_file "path/default_filename" {* Change *}
  LET gv_file_existent 0
  TRAP_ERROR
    LOAD File_1
  IF (CHECK_ERROR)
    DISPLAY("File "+File_1+" not existent. Load Default File? Yes= any key | No= ESC ")
    LOAD Default_file
  ELSE
    LET gv_file_existent 1
  END_IF
END_DEFINE


ludw 11-25-2015 10:24 PM

Re: load file defined
 
You may also consider SEARCH command. With SEARCH you may enter different directories from where the LOAD command will try to find out and load the file to LOAD.
Ex: LOAD "myfile"
will try to locate and load "myfile" in each ordered directories specified by SEARCH.
To know about your SEARCH settings, let use EDIT_ENVIRONMENT.


All times are GMT -8. The time now is 11:05 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.