Function 'import' don't work with variables

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 !

Maybe try…

foreach lib in=[/file find name~".lib.rsc"] do={ :local libname [/file get $lib name]; :put $libname; /import "$libname" }

And I think it’s normal behaviour, not a bug :slight_smile:.
Your $lib variable is not “string”, but a pointer to a file (try :put $lib, instead of :put [/file get $lib name]) :slight_smile:. 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 :slight_smile:.

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 !