Rene
New Member
Posts: 4
|
Post by Rene on Dec 30, 2015 11:23:48 GMT -5
Hi, I'm working on my first macros (yes, I'm reading the manual ). If I run a certain task I want to use the #include statement. If I specify the full path to the macro folder (c:\Users\myname\Documents\SPFLite\Macros) it works OK, however I'd like to specify this in a more flexible way. So I thought of using the Get_INI_Path$ function, but somehow I can't get this done. I stripped it to the following very simple macros: ' MYMAC1.MACRO dim macfolder as string dim mymac2 as string macfolder = Get_INI_Path$ + "Macros\" mymac2 = macfolder + "mymac2.macro" uses "console" printl mymac2 #include mymac2 Halt ' MYMAC2.MACRO uses "console" printl "this is mymac2" halt the printl statement in mymac1 show the correct path and filename but the include statement gives an error 'include file not found' Any idea what I'm doing wrong? Thanks, Rene
|
|
|
Post by George on Dec 31, 2015 12:55:52 GMT -5
Rene:
Welcome to SPFLite, nice to see someone trying out Macros.
As you said "reading the manual" - great - but you missed the comment in the thinBasic #INCLUDE documentation:
This directive is a pre parsing directive. It means all #INCLUDE statements will be solved before starting script execution.
(Under ThinBasic Language => Script Structure => Pre Parsing Directives => #INCLUDE)
Which means basically the included filename cannot be built from any variable strings, only literals, since the script has not yet even begun to execute.
Sorry,
George
|
|
Rene
New Member
Posts: 4
|
Post by Rene on Jan 1, 2016 11:43:22 GMT -5
Hi George and Robert, Thanks for the explanation. It's clear now, although a pity it works like this... I'll check out the best alternative for me, option 1 or 2 as indicated by you Robert. Nevertheless it's big fun writing editmacro's, it reminds me of my MVS SysPro time at IBM >20 years ago. Regards and the best wishes for 2016! Rene
|
|
|
Post by erosolmi on Jan 13, 2016 13:36:32 GMT -5
Hi Robert/George, next thinBasic version (1.9.16.10) will have new meta statements working in #INCLUDE and #INCLUDEDIR If present one of the following meta statement, it will be resolved and substituted by the corresponding operating system path. Hope this can help Ciao Eros Example: #INCLUDE "%CSIDL_LOCAL_APPDATA\Project01\Includes\object_*.tbasic" More info about CLSIDL meaning at: msdn.microsoft.com/it-it/library/windows/desktop/bb762494(v=vs.85).aspxList of meta: %CSIDL_ADMINTOOLS %CSIDL_ALTSTARTUP %CSIDL_APPDATA %CSIDL_BITBUCKET %CSIDL_CDBURN_AREA %CSIDL_COMMON_ADMINTOOLS %CSIDL_COMMON_ALTSTARTUP %CSIDL_COMMON_APPDATA %CSIDL_COMMON_DESKTOPDIRECTORY %CSIDL_COMMON_DOCUMENTS %CSIDL_COMMON_FAVORITES %CSIDL_COMMON_MUSIC %CSIDL_COMMON_PICTURES %CSIDL_COMMON_PROGRAMS %CSIDL_COMMON_STARTMENU %CSIDL_COMMON_STARTUP %CSIDL_COMMON_TEMPLATES %CSIDL_COMMON_VIDEO %CSIDL_CONTROLS %CSIDL_COOKIES %CSIDL_DESKTOP %CSIDL_DESKTOPDIRECTORY %CSIDL_DRIVES %CSIDL_FAVORITES %CSIDL_FLAG_CREATE %CSIDL_FONTS %CSIDL_HISTORY %CSIDL_INTERNET %CSIDL_INTERNET_CACHE %CSIDL_LOCAL_APPDATA %CSIDL_MYDOCUMENTS %CSIDL_MYMUSIC %CSIDL_MYPICTURES %CSIDL_MYVIDEO %CSIDL_NETHOOD %CSIDL_NETWORK %CSIDL_PERSONAL %CSIDL_PRINTERS %CSIDL_PRINTHOOD %CSIDL_PROFILE %CSIDL_PROGRAM_FILES %CSIDL_PROGRAM_FILES_COMMON %CSIDL_PROGRAMS %CSIDL_RECENT %CSIDL_SENDTO %CSIDL_STARTMENU %CSIDL_STARTUP %CSIDL_SYSTEM %CSIDL_TEMPLATES %CSIDL_WINDOWS
|
|
|
Post by erosolmi on Jan 14, 2016 11:48:18 GMT -5
Ciao Robert, regarding #INCLUDE, yes, if there is no path in the file name, thinBasic try a sequence of paths: - first the path of the script (if script is file based)
- then exetable path + \Inc\
- if file is still not found, it search into all #INCLUDEDIR found into the script
Adding all new meta paths will for sure add more options but not all the possibilities. So having your pre-processor and adding dynamically a possible path is currently the only solution. As a possible solution for your user base, I can add a new SDK function so you can inject the path directly into thinBasic Core engine before executing thinBasic_Run. Something like thinBasic_AddIncludeDir("c:\MyApp\MyIncDir\"). What do you think?Regarding FOR ... WHEN is already developed. I added into version 1.9.16.6 in December. See www.thinbasic.com/public/products/thinBasic/help/html/index.html?version_1_9_16_x.htmPlease check if it is working as you expect. Ciao Eros
|
|
|
Post by George on Jan 14, 2016 11:50:49 GMT -5
Well, %CSIDL_PERSONAL would give us the C:\Users\Whoever\Documents folder. Add \SPFLite\Macros to it and we have the right folder.
SPFLite already uses %CSIDL_PERSONAL to locate its' proper INI folder. ( \Documents\SPFLite\ )
George
|
|
|
Post by erosolmi on Jan 14, 2016 16:41:03 GMT -5
Just published thinBasic 1.9.16.10
After installation, in \thinBasic\SDK\SDK.zip\thinBasic BASIC SDK\PB\ you will find new PB include file thinCore.inc in which there is the declaration of new SDK function thinBasic_AddIncludePath(sPath) Use this function between thinBasic_Init(...) and thinBasic_Run(...)
Hope it will work because I had no time to test. Let me know.
Ciao Eros
|
|
|
Post by George on Jan 17, 2016 12:48:36 GMT -5
Eros: OK, I guess I'll have to get off my butt and move to your latest thinBasic version. I haven't upgraded up to now for the simple "let's not rock the boat" reason. The version we had did what we wanted so ....
I will have a go at this and let you know the results.
George
|
|
|
Post by George on Jan 24, 2016 14:07:14 GMT -5
Eros:
OK, I've upgraded SPFLite to use your latest version (I've seen no problems of inconsistencies yet), and the AddIncludePath function seems to work just fine. Many thanks.
George
|
|