Community discussions

 
User avatar
yo1frenchtoast
just joined
Topic Author
Posts: 8
Joined: Thu Jul 09, 2015 3:48 pm
Location: Brittany, France

Function 'import' don't work with variables

Mon Jun 25, 2018 2:37 pm

Hello,

I have an issue with the function 'import', it canno't take variables as arguments :
[ansible@que-1-hap] > foreach lib in=[/file find name~".lib.rsc"] do={ put [/file get $lib name] }
convertCase.lib.rsc
diffDate.lib.rsc
getUserContact.lib.rsc
netwatchAction.lib.rsc
sendSms.lib.rsc
sendTelegram.lib.rsc
[ansible@que-1-hap] > foreach lib in=[/file find name~".lib.rsc"] do={ put [/file get $lib name]; import $lib }
convertCase.lib.rsc
cannot open import file, 		    file does not exist

[ansible@que-1-hap] > import 
convertCase.lib.rsc  diffDate.lib.rsc  getUserContact.lib.rsc  last-export.rsc  netwatchAction.lib.rsc  sendSms.lib.rsc  sendTelegram.lib.rsc  from-line  verbose  file-name
[ansible@que-1-hap] >
Context : I'm making 'libraires' (global functions), so I made a bash script to deploy them (the 'foreach' line as in the exemple above)

It must be a new feature to develop =)

Have a nice day !
 
User avatar
dasiu
Trainer
Trainer
Posts: 232
Joined: Fri Jan 30, 2009 11:41 am
Location: Reading, UK
Contact:

Re: Function 'import' don't work with variables

Tue Jun 26, 2018 1:28 pm

Maybe try...
foreach lib in=[/file find name~".lib.rsc"] do={ :local libname [/file get $lib name]; :put $libname; /import "$libname" }
 
User avatar
dasiu
Trainer
Trainer
Posts: 232
Joined: Fri Jan 30, 2009 11:41 am
Location: Reading, UK
Contact:

Re: Function 'import' don't work with variables

Tue Jun 26, 2018 1:32 pm

And I think it's normal behaviour, not a bug :).
Your $lib variable is not "string", but a pointer to a file (try :put $lib, instead of :put [/file get $lib name]) :). You can use it in /file menu, but not in /import. You can also do /file print, find the entry number you like, and then remove it with "/file remove 3", for example. But you can't do "/import 3" the same way. That's why you need to get full name and use it with /import, that was the problem you had :).
 
User avatar
yo1frenchtoast
just joined
Topic Author
Posts: 8
Joined: Thu Jul 09, 2015 3:48 pm
Location: Brittany, France

Re: Function 'import' don't work with variables

Wed Jun 27, 2018 2:59 pm

Yes thank you =)

I don't know how I could have missed it... Maybe some sleep could have helped me

Thank you a lot again !

Who is online

Users browsing this forum: No registered users and 12 guests