Have @dir in a compiled program point to current directory?

Discussions related to the supplied tools and add-in utilities
Hated Moron

Re: Have @dir in a compiled program point to current directory?

Post by Hated Moron »

jeroen_soutberg wrote: Fri 19 Jan 2024, 10:28 I would like to be able to use @dir$ in a compiled program in the same way as I can use it in the original program, e.g., having PRINT @dir$ printing the directory in which the program/the exe is run.
That's supposed to be exactly what it does! As I explained, the purpose of @dir$ is to enable compiled programs to run correctly, including accessing their resource files, even when installed on a completely different computer which doesn't have BBC BASIC or any of the needed files installed - or in a web browser!

If you are finding that this isn't working correctly please give me instructions for how to reproduce the issue here. But there can't be anything major wrong, because thousands of BBC BASIC programs do run correctly when compiled, and accessing their resources via @dir$. I specifically gave the example of David Williams' program 'Forces of Darkness' which has hundreds of resource files (sub-modules, graphics, sounds etc.).

Here again is the link to run Forces of Darkness in your own browser, it couldn't possibly run if @dir$ was not working correctly. Just look at the REM!Embed directives in that program (yes, support for wildcards would be very helpful):

Code: Select all

      REM!Embed @dir$+"Resources/Data/blackghostpath.DAT"
      REM!Embed @dir$+"Resources/Data/demodata_X86.DAT"
      REM!Embed @dir$+"Resources/Data/demodata_ARM.DAT"
      REM!Embed @dir$+"Resources/Data/path0.DAT"
      REM!Embed @dir$+"Resources/Data/path1.DAT"
      REM!Embed @dir$+"Resources/Data/snailpath.DAT"
      REM!Embed @dir$+"Resources/Data/snakepath.DAT"
      REM!Embed @dir$+"Resources/Data/witch1path.DAT"
      REM!Embed @dir$+"Resources/Data/ylist.DAT"

      REM!Embed @dir$+"Resources/Data/paths/babyskulls.DAT"
      REM!Embed @dir$+"Resources/Data/paths/bats.DAT"
      REM!Embed @dir$+"Resources/Data/paths/bats2.DAT"
      REM!Embed @dir$+"Resources/Data/paths/bluedevils.DAT"
      REM!Embed @dir$+"Resources/Data/paths/coffins.DAT"
      REM!Embed @dir$+"Resources/Data/paths/devils1.DAT"
      REM!Embed @dir$+"Resources/Data/paths/devils2.DAT"
      REM!Embed @dir$+"Resources/Data/paths/doubleloop.DAT"
      REM!Embed @dir$+"Resources/Data/paths/eyeballs1.DAT"
      REM!Embed @dir$+"Resources/Data/paths/eyeballs2.DAT"
      REM!Embed @dir$+"Resources/Data/paths/fishes.DAT"
      REM!Embed @dir$+"Resources/Data/paths/franks1.DAT"
      REM!Embed @dir$+"Resources/Data/paths/greenghosts.DAT"
      REM!Embed @dir$+"Resources/Data/paths/hands.DAT"
      REM!Embed @dir$+"Resources/Data/paths/hands2.DAT"
      REM!Embed @dir$+"Resources/Data/paths/loop.DAT"
      REM!Embed @dir$+"Resources/Data/paths/maggots1.DAT"
      REM!Embed @dir$+"Resources/Data/paths/pumpkins.DAT"
      REM!Embed @dir$+"Resources/Data/paths/skulls2.DAT"
      REM!Embed @dir$+"Resources/Data/paths/snake2.DAT"
      REM!Embed @dir$+"Resources/Data/paths/snake3.DAT"
      REM!Embed @dir$+"Resources/Data/paths/spiders2.DAT"
      REM!Embed @dir$+"Resources/Data/paths/spiders3.DAT"
      REM!Embed @dir$+"Resources/Data/paths/teeth1.DAT"
      REM!Embed @dir$+"Resources/Data/paths/vecballs.DAT"
      REM!Embed @dir$+"Resources/Data/paths/whiteghosts.DAT"
      REM!Embed @dir$+"Resources/Data/paths/witches1.DAT"
      REM!Embed @dir$+"Resources/Data/paths/witches2.DAT"

      REM!Embed @dir$+"Resources/Data/farbg2.png"
      REM!Embed @dir$+"Resources/Data/fg.png"
      REM!Embed @dir$+"Resources/Data/midbg2.png"

      REM!Embed @dir$+"Resources/Graphics/gameover/bloodstrip_1x64_3.png"
      REM!Embed @dir$+"Resources/Graphics/gameover/disc_64x64.png"
      REM!Embed @dir$+"Resources/Graphics/gameover/gameover_477x56.png"

      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_0.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_1.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_2.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_3.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_4.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_5.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_6.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_7.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_8.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_9.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_10.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_11.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_12.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_13.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_14.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_15.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_16.png"
      REM!Embed @dir$+"Resources/Graphics/groundobjs/spr_17.png"

      REM!Embed @dir$+"Resources/Graphics/hero/crucifix_370x480.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_-1.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_-2.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_-3.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_-4.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_-5.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_-6.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_-7.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_-8.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_-9.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_-10.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_-11.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_-12.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_0.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_1.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_2.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_3.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_4.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_5.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_6.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_7.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_8.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_9.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_10.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_11.png"
      REM!Embed @dir$+"Resources/Graphics/hero/crux_100x77_12.png"
      REM!Embed @dir$+"Resources/Graphics/hero/fireball_64x64.png"
      REM!Embed @dir$+"Resources/Graphics/hero/firepower0_48x48.png"
      REM!Embed @dir$+"Resources/Graphics/hero/firepower1_48x48.png"
      REM!Embed @dir$+"Resources/Graphics/hero/firepower2_48x48.png"
      REM!Embed @dir$+"Resources/Graphics/hero/firepower3_48x48.png"
      REM!Embed @dir$+"Resources/Graphics/hero/firepower_red_48x48.png"
      REM!Embed @dir$+"Resources/Graphics/hero/glitter_32x32.png"
      REM!Embed @dir$+"Resources/Graphics/hero/health_126x30.png"
      REM!Embed @dir$+"Resources/Graphics/hero/life_32x32.png"
      REM!Embed @dir$+"Resources/Graphics/hero/particle_8x8.png"
      REM!Embed @dir$+"Resources/Graphics/hero/projectile_12x12.png"
      REM!Embed @dir$+"Resources/Graphics/hero/shield_120x120.png"

      REM!Embed @dir$+"Resources/Graphics/ingamelightning/lightning0.png"
      REM!Embed @dir$+"Resources/Graphics/ingamelightning/lightning1.png"
      REM!Embed @dir$+"Resources/Graphics/ingamelightning/lightning2.png"

      REM!Embed @dir$+"Resources/Graphics/intro/CodeAGameCompo_1920x780.png"
      REM!Embed @dir$+"Resources/Graphics/intro/fod_290x224.png"
      REM!Embed @dir$+"Resources/Graphics/intro/lightning2_480x480.png"
      REM!Embed @dir$+"Resources/Graphics/intro/lightning_480x480.png"
      REM!Embed @dir$+"Resources/Graphics/intro/pumpkin_690x480.png"
      REM!Embed @dir$+"Resources/Graphics/intro/skull_494x480.png"
      REM!Embed @dir$+"Resources/Graphics/intro/SyntaxBomb_1860x360.png"

      REM!Embed @dir$+"Resources/Graphics/misc/close_24x24.png"
      REM!Embed @dir$+"Resources/Graphics/misc/colourtable_180x1.png"
      REM!Embed @dir$+"Resources/Graphics/misc/fade_rect_852x64.png"
      REM!Embed @dir$+"Resources/Graphics/misc/plain_white_213x120.png"

      REM!Embed @dir$+"Resources/Graphics/nasties/ammotype5_53x43.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/babyskull_80x110.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/babyskull_wing_left.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/babyskull_wing_right.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/ball17x17.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/batbody_48x48.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/batwing1_24x64.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/batwing2_24x64.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/beetle_64x55.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/bigeye_128x128.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/bigwitch_head_214x450.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/bigwitch_jaw_97x143.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/blackghost_157x256.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/blooddrop_28x47.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/blooddrop_64x80.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/bubble_32x32.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/cauldron_100x76.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/cauldron_outline_100x76.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/coffin_36x80.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/crow_body_left_flying1_64x64.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/crow_body_left_flying2_64x64.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/crow_body_right_flying1_64x64.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/crow_body_right_flying2_64x64.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/crow_leg_left_32x32.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/crow_leg_right_32x32.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/crow_sitting_73x64.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/crow_wing_left_80x35.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/crow_wing_right_80x35.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/devil_2_64x72.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/devil_3_80x80.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/devil_64x72.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/evil_skeleton_90x128.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/evil_skull_32x32.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/eye_64x64.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/fireball2_20x20.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/fireball4_48x48.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/fireball5_128x128.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/fireball_16x16.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/fish_50x128.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/frank_131x159.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/ghost2_64x98.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/ghoul1_80x73.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/gooblob_64x64_0.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/greenexp_128x128.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/green_ghost_80x57.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/hand_91x91.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/pumpkin_96x80.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/pusblobmask_32x32.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/pusblob_32x32.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/redexp_128x128.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/semisphere_1_96x81.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/semisphere_2_96x81.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/semisphere_dead_1_96x81.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/semisphere_dead_2_96x81.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/skull_68x72.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/snakebody_65x80.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/snakehead_65x80.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/spider1_80x63.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/spider2_70x70.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/strip17x1.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/teeth_80x50.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/whiteexp_128x128.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/whitering_64x64.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/witch1_159x93.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/witch2_93x159.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/yellowdrop_28x47.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/yellowexp_128x128.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zap_20x60.png"

      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_0.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_1.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_2.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_3.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_4.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_5.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_6.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_7.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_8.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_9.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_10.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_11.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_12.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_13.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_14.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_15.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_16.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_17.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_18.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_19.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_20.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_21.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_22.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_23.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_24.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_25.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_26.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_27.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_28.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_29.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_30.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_31.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_32.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_33.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_34.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_35.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_36.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_37.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_38.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_39.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_40.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_41.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_42.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_43.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_44.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/maggot/maggot_85x140_45.png"

      REM!Embed @dir$+"Resources/Graphics/nasties/snail1/snail1_48x72_0.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/snail1/snail1_48x72_1.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/snail1/snail1_48x72_2.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/snail1/snail1_48x72_3.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/snail1/snail1_48x72_4.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/snail1/snail1_48x72_5.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/snail1/snail1_48x72_6.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/snail1/snail1_48x72_7.png"

      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_0.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_1.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_2.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_3.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_4.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_5.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_6.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_7.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_8.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_9.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_10.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_11.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_12.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_13.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_14.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_15.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_16.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_17.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_18.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_19.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_20.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_21.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_22.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_23.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_24.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_25.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_26.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_27.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_28.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_29.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_30.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_31.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_32.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_33.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_34.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_35.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_36.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_37.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_38.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_39.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_40.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_41.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_42.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_43.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_44.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_45.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_46.png"
      REM!Embed @dir$+"Resources/Graphics/nasties/zombie1/zombie1_47.png"

      REM!Embed @dir$+"Resources/Graphics/titlepage/blooddrop_32x48.png"
      REM!Embed @dir$+"Resources/Graphics/titlepage/button_cross_32x32.png"
      REM!Embed @dir$+"Resources/Graphics/titlepage/button_tick_32x32.png"
      REM!Embed @dir$+"Resources/Graphics/titlepage/fod_344x240.png"
      REM!Embed @dir$+"Resources/Graphics/titlepage/mask_left_48x160.png"
      REM!Embed @dir$+"Resources/Graphics/titlepage/mask_right_48x160.png"

      REM!Embed @dir$+"Resources/Graphics/tokens/text_autofire_372x62.png"
      REM!Embed @dir$+"Resources/Graphics/tokens/text_extralife_420x62.png"
      REM!Embed @dir$+"Resources/Graphics/tokens/text_healthboost_566x63.png"
      REM!Embed @dir$+"Resources/Graphics/tokens/text_powerup_393x63.png"
      REM!Embed @dir$+"Resources/Graphics/tokens/text_shield_275x63.png"
      REM!Embed @dir$+"Resources/Graphics/tokens/token_autofire_48x48.png"
      REM!Embed @dir$+"Resources/Graphics/tokens/token_extralife_48x48.png"
      REM!Embed @dir$+"Resources/Graphics/tokens/token_health_48x48.png"
      REM!Embed @dir$+"Resources/Graphics/tokens/token_mystery_48x48.png"
      REM!Embed @dir$+"Resources/Graphics/tokens/token_powerup_48x48.png"
      REM!Embed @dir$+"Resources/Graphics/tokens/token_shield_48x48.png"

      REM!Embed @dir$+"Resources/Lib/BigWitch.bbc"
      REM!Embed @dir$+"Resources/Lib/EvilSkulls.bbc"
      REM!Embed @dir$+"Resources/Lib/Intro.bbc"

      REM!Embed @dir$+"Resources/Lib/FN/FNatan2.bbc"
      REM!Embed @dir$+"Resources/Lib/FN/FNDefineWaves.bbc"
      REM!Embed @dir$+"Resources/Lib/FN/FNGetFirepowerDecayRate.bbc"
      REM!Embed @dir$+"Resources/Lib/FN/FNLoadPathData.bbc"

      REM!Embed @dir$+"Resources/Lib/PROC/PathHandlers.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCAnimateNasty.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateBloodDrops.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateBloodDrops2.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateGameOverAnimationFrames.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateGooBlobs.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateHeroFireballs.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateNastyAmmo.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateNastyExplosion.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateNastyExplosion2.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateNewLine.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateNewNasty.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateNewProjectile.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateNewWave.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreatePusBlobs.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateSnakeSprites.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateSparks.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateSparkSprites.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateTokenExpansion.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateWhiteRings.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCCreateYellowDrops.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCDesaturateBlur.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCDestroySnake.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCDrawAndUpdateBloodDrop.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCDrawAndUpdateGooBlob.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCDrawAndUpdatePusBlob.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCDrawAndUpdateWhiteRing.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCDrawAndUpdateYellowDrop.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCDrawCrow.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCDrawNasty.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCDrawNastyShadow.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCDrawShield.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCDrawSpark.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCDrawToken.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCFullScreenFallAwayEffect.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCFuzzyBlackDiscsFade.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCGenerateAnimatedBat.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCGenerateAnimatedWhiteGhost.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCGenerateToken.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCGetRotatedOffsetCoords.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCHandleCauldronBubbles.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCHandleHero.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCHandleHeroFireballs.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCHandleHeroObjectCollision.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCHandleHero_DemoMode.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCHandleHero_SaveDemoData.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCHandleNasty.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCHandleNastyAmmo.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCHandleNastyExplosion.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCHandleProjectile.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCHandleSparks.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCHandleTokenExpansion.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCInitGreenBubble.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCInitNewGame.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCLoadAndRotateNastySprite.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCLoadAnimatedNastyRawSprite.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCLoadAnimatedNastySprite.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCLoadSingleNastySprite.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCMakeSingleNastySprite.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyShadowType17.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyShadowType18.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyShadowType2.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyShadowType22.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyShadowType23.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyShadowTypes01.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyType0.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyType1.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyType16.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyType17.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyType18.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyType19.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyType2.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyType20.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyType21.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyType22.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCPlotNastyType23.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCResetHero.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCResetSparkBezierNodes.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCRotPoint2D.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCSortWaves.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCTheDrippingBloodEffect.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/PROCVictory.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/TitlePage.bbc"
      REM!Embed @dir$+"Resources/Lib/PROC/WaveDefiners.bbc"

      REM!Embed @dir$+"Resources/Music/soundtracks.mp3"
      REM!Embed @dir$+"Resources/Music/silence.mp3"
      REM!Embed @dir$+"Resources/SoundFx/101934_juskiddink_dry-thunder2.mp3"
      REM!Embed @dir$+"Resources/SoundFx/128349_kafokafo_laser.mp3"
      REM!Embed @dir$+"Resources/SoundFx/173933_johnsonbrandediting_cartoon-laugh.mp3"
      REM!Embed @dir$+"Resources/SoundFx/214990_peridactyloptrix_laser-blast-x3.mp3"
      REM!Embed @dir$+"Resources/SoundFx/218193_madamvicious_witch-death.mp3"
      REM!Embed @dir$+"Resources/SoundFx/253524_nanakisan_evil-laugh-2.mp3"
      REM!Embed @dir$+"Resources/SoundFx/253533_nanakisan_evil-laugh-7.mp3"
      REM!Embed @dir$+"Resources/SoundFx/256830_dneproman_dark-texture-2.mp3"
      REM!Embed @dir$+"Resources/SoundFx/321103_nsstudios_blip1.mp3"
      REM!Embed @dir$+"Resources/SoundFx/325261_adam-n_whoosh.mp3"
      REM!Embed @dir$+"Resources/SoundFx/335168_jorgepotter_bongs-2.mp3"
      REM!Embed @dir$+"Resources/SoundFx/335990_klangfabrik_explosion007.mp3"
      REM!Embed @dir$+"Resources/SoundFx/336001_ev-dawg_metal-grinding-very-slow.mp3"
      REM!Embed @dir$+"Resources/SoundFx/348192_konstantinusz_000-crow.mp3"
      REM!Embed @dir$+"Resources/SoundFx/361471_sunnyflower_laser-gun_modified.mp3"
      REM!Embed @dir$+"Resources/SoundFx/383654_deleted-user-7146007_electricity_2.mp3"
      REM!Embed @dir$+"Resources/SoundFx/42793_digifishmusic_australian-magpie_1.mp3"
      REM!Embed @dir$+"Resources/SoundFx/42793_digifishmusic_australian-magpie_2.mp3"
      REM!Embed @dir$+"Resources/SoundFx/42793_digifishmusic_australian-magpie_3.mp3"
      REM!Embed @dir$+"Resources/SoundFx/60006_qubodup_swoosh.mp3"
      REM!Embed @dir$+"Resources/SoundFx/76405_dsp9000_old-church-bell.mp3"
      REM!Embed @dir$+"Resources/SoundFx/ANGELS_3_modified.mp3"
      REM!Embed @dir$+"Resources/SoundFx/bang2_0.mp3"
      REM!Embed @dir$+"Resources/SoundFx/bang_splat_0.mp3"
      REM!Embed @dir$+"Resources/SoundFx/bang_splat_1.mp3"
      REM!Embed @dir$+"Resources/SoundFx/bang_splat_2.mp3"
      REM!Embed @dir$+"Resources/SoundFx/bang_splat_3.mp3"
      REM!Embed @dir$+"Resources/SoundFx/bang_splat_4.mp3"
      REM!Embed @dir$+"Resources/SoundFx/bang_splat_5.mp3"
      REM!Embed @dir$+"Resources/SoundFx/bang_splat_6.mp3"
      REM!Embed @dir$+"Resources/SoundFx/bang_splat_7.mp3"
      REM!Embed @dir$+"Resources/SoundFx/bang_splat_8.mp3"
      REM!Embed @dir$+"Resources/SoundFx/BONGOLO2.mp3"
      REM!Embed @dir$+"Resources/SoundFx/bubbling.mp3"
      REM!Embed @dir$+"Resources/SoundFx/BUTTON12.mp3"
      REM!Embed @dir$+"Resources/SoundFx/cauldron_destroyed.mp3"
      REM!Embed @dir$+"Resources/SoundFx/cinematicboom.mp3"
      REM!Embed @dir$+"Resources/SoundFx/clickbutton.mp3"
      REM!Embed @dir$+"Resources/SoundFx/DRY_HIGH.mp3"
      REM!Embed @dir$+"Resources/SoundFx/GameCompleted.mp3"
      REM!Embed @dir$+"Resources/SoundFx/goo_splat_0.mp3"
      REM!Embed @dir$+"Resources/SoundFx/goo_splat_1.mp3"
      REM!Embed @dir$+"Resources/SoundFx/goo_splat_2.mp3"
      REM!Embed @dir$+"Resources/SoundFx/goo_splat_3.mp3"
      REM!Embed @dir$+"Resources/SoundFx/goo_splat_4.mp3"
      REM!Embed @dir$+"Resources/SoundFx/goo_splat_5.mp3"
      REM!Embed @dir$+"Resources/SoundFx/health_low.mp3"
      REM!Embed @dir$+"Resources/SoundFx/herostruck0.mp3"
      REM!Embed @dir$+"Resources/SoundFx/herostruck1.mp3"
      REM!Embed @dir$+"Resources/SoundFx/herostruck2.mp3"
      REM!Embed @dir$+"Resources/SoundFx/herostruck3.mp3"
      REM!Embed @dir$+"Resources/SoundFx/herostruck4.mp3"
      REM!Embed @dir$+"Resources/SoundFx/herostruck5.mp3"
      REM!Embed @dir$+"Resources/SoundFx/herostruck6.mp3"
      REM!Embed @dir$+"Resources/SoundFx/herostruck7.mp3"
      REM!Embed @dir$+"Resources/SoundFx/herostruck8.mp3"
      REM!Embed @dir$+"Resources/SoundFx/herostruck9.mp3"
      REM!Embed @dir$+"Resources/SoundFx/hero_laser_shot_0.mp3"
      REM!Embed @dir$+"Resources/SoundFx/hero_laser_shot_1.mp3"
      REM!Embed @dir$+"Resources/SoundFx/hero_laser_shot_2.mp3"
      REM!Embed @dir$+"Resources/SoundFx/hero_laser_shot_3.mp3"
      REM!Embed @dir$+"Resources/SoundFx/hiss1_dw.mp3"
      REM!Embed @dir$+"Resources/SoundFx/hiss2_dw.mp3"
      REM!Embed @dir$+"Resources/SoundFx/hit_by_spark.mp3"
      REM!Embed @dir$+"Resources/SoundFx/nasty_struck.mp3"
      REM!Embed @dir$+"Resources/SoundFx/short_blank.mp3"
      REM!Embed @dir$+"Resources/SoundFx/sparker_destroyed.mp3"
      REM!Embed @dir$+"Resources/SoundFx/token0.mp3"
      REM!Embed @dir$+"Resources/SoundFx/token1.mp3"
      REM!Embed @dir$+"Resources/SoundFx/token2.mp3"
      REM!Embed @dir$+"Resources/SoundFx/token3.mp3"
      REM!Embed @dir$+"Resources/SoundFx/token4.mp3"
      REM!Embed @dir$+"Resources/SoundFx/token5.mp3"
      REM!Embed @dir$+"Resources/SoundFx/witch_laughing.mp3"

      REM!Embed @dir$+"Resources/SoundFx/0/scream0.mp3"
      REM!Embed @dir$+"Resources/SoundFx/0/scream1.mp3"
      REM!Embed @dir$+"Resources/SoundFx/0/scream2.mp3"
      REM!Embed @dir$+"Resources/SoundFx/0/scream3.mp3"
      REM!Embed @dir$+"Resources/SoundFx/0/scream4.mp3"
      REM!Embed @dir$+"Resources/SoundFx/0/scream5.mp3"
      REM!Embed @dir$+"Resources/SoundFx/0/scream6.mp3"
      REM!Embed @dir$+"Resources/SoundFx/0/scream7.mp3"
      REM!Embed @dir$+"Resources/SoundFx/0/scream8.mp3"
      REM!Embed @dir$+"Resources/SoundFx/0/scream9.mp3"
      REM!Embed @dir$+"Resources/SoundFx/0/scream10.mp3"
      REM!Embed @dir$+"Resources/SoundFx/0/thunder0.mp3"
      REM!Embed @dir$+"Resources/SoundFx/0/thunder1.mp3"
jeroen_soutberg
Posts: 9
Joined: Mon 08 Aug 2022, 14:26

Re: Have @dir in a compiled program point to current directory?

Post by jeroen_soutberg »

Many thanks for responding again, and sorry for the inconvenience.

There must be something I am interpreting/understanding incorrectly, so I tried the very simplest test I could think of:

Code: Select all

PRINT @dir$
I ran the program in the directory P:\foto\M50, and as expected, this showed P:\foto\M50\

When compiled, and the exe copied to another directory, the result of running the exe is the path to the temporary directory created for the occasion, e.g. D:\jstmp\BBC432.tmp\, not the the path to the directory in which the exe is run.

Jeroen
Hated Moron

Re: Have @dir in a compiled program point to current directory?

Post by Hated Moron »

jeroen_soutberg wrote: Sat 20 Jan 2024, 07:42 When compiled, and the exe copied to another directory, the result of running the exe is the path to the temporary directory created for the occasion, e.g. D:\jstmp\BBC432.tmp\, not the the path to the directory in which the exe is run.
That's because your program did not have any embedded files in @dir$. If there are no such files, it doesn't matter what @dir$ points to, because there are no files to access using it! In that case @dir$ is undefined.

If you look at the documentation of @dir$ you will see that it is specified as being for use "when loading any other resource files (images, data files etc.) needed by your program". If there are no such files, it can be anything!

If what you are looking for is a variable which always points to the directory containing the executable, even when there are no embedded files, I'm afraid that does not exist. But you need only embed at least one file in @dir$ to achieve that.

It's important to realise that your program should not, in any case, be loading files - which were not embedded in the executable - from its own directory. How would such files get there in the first place? ;)

In general, applications are not installed in locations which are writable by normal users. For example, in Windows, (32-bit) applications are normally installed in C:\Program Files (x86)\ which is writable only by an administrator.

If you want your program to have the capability of loading files which were saved by the user, those files should be in @usr$ (which is guaranteed to be writable by the user, and specific to that user) not in @dir$.
jgharston
Posts: 37
Joined: Thu 05 Apr 2018, 14:08

Re: Have @dir in a compiled program point to current directory?

Post by jgharston »

On Windows there is a way to read what the executed program's execution pathname is, and so from that you get the path to the directory the executed program is in.
DIM X% 256
SYS "GetModuleFileName",0,X%,255
runpath$=$$X%
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: Have @dir in a compiled program point to current directory?

Post by Richard Russell »

jgharston wrote: Fri 15 Nov 2024, 22:40 On Windows there is a way to read what the executed program's execution pathname is, and so from that you get the path to the directory the executed program is in.
But it suffers from exactly the same 'flaw' as @dir$: it doesn't return the 'expected' directory if there are no embedded resource files. If I compile and run your code, after adapting it for BBCSDL, both return the same information:

Code: Select all

      DIM X%% 256
      SYS "GetModuleFileNameA",0,X%%,255
      PRINT "GMFNA = "; $$X%%
      PRINT "@dir$ = "; @dir$
Try it yourself if you're not sure.