[Gambas-user] Help with understanding how not to hard-code paths

Joshua Higgins joshiggins at ...1601...
Mon Aug 18 01:53:08 CEST 2008


What I would do in this situation is this. Use a module, say MProgram to
store settings like the path to the data for your program in. Inside that
module have a public string for the path: PUBLIC path AS STRING. Now all you
need to do is ask the user for the path to the data files, and replace all
the hard coded links with
MProgram.Path & "whatever".

As for the html part, now your program can, using MProgram.Path, hard code a
correct path into the html.

e.g. your program writes "<IMG SRC=" & MProgram.Path & "blah blah...." to
the html.

hope this helps.

p.s. a much simpler solution would be to move everything into a system-wide
folder such as /usr/share/your_app_name and hard code everything to there
instead, then just copy that too when you move your program to another
machine.

On Sat, Aug 16, 2008 at 1:26 PM, richard terry <rterry at ...1946...>wrote:

> I've got to the point with my program where I need to  remove hard coding
> references I used when starting to develop the concepts of my program, so
> I'd
> like to ask for some advice how to do this, in a couple of situations.
>
> 1) When the program runs
>
> 2) To do with html I've saved to my database, where I've put checkboxes on
> a
> form, by using an image. Probably there is a proper way to do this with
> html?.
>
> e.g in one of my files I end up with this html:
>
> <IMG SRC='/home/richard/coding/gambas2/gb2/icons/12/checkbox_checked.png'
> NAME=5%image_name%' ALIGN=LEFT WIDTH=15 HEIGHT=15 BORDER=0>Fasting<BR
> CLEAR=LEFT><IMG
>
> Which obviously is not much good if I later want to show it on another
> machine.
>
> Any help appreciated, and thanks in advance.
>
> Richard
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
joshua higgins
>>>>>>------



More information about the User mailing list