#1 Thu 22 November 2012 11:11
- thomas17180
- Participant actif
- Lieu: La Rochelle
- Date d'inscription: 9 May 2011
- Messages: 50
[MapBasic] Bouton parcourir "..." ne marche pas!
Bonjour à tous,
Je developpe un petit programme assez simple mais j'ai un problème!!!
Voici l'interface :
[img]http://nsa31.casimages.com/img/2012/11/20/12112003073922260.jpg[/img]
Dans la première liste, j'affiche les tables déjà ouvertes dans MapInfo (pas de problèmes).
La seconde liste devrait afficher la table qu'on choisie en cliquant sur le bouton "...". Celui-ci affiche une boite de dialogue mais une fois choisie, la table n'apparait pas dans ma liste... (d'ailleurs est-il possible de limiter cette liste à une seule valeur???)
Voici le code qui correspond au programme :
Code:
'-----------------------------------------------------------------------------------------------------------------
'-----------------------------------------------------------------------------------------------------------------
'-------------------------------------------- Code par Thomas Mahé -----------------------------------------------
'-------------------------------------- Contact : thomas.mahe17@gmail.com ----------------------------------------
'-----------------------------------------------------------------------------------------------------------------
'-----------------------------------------------------------------------------------------------------------------
Include "mapbasic.def"
Declare sub main
Declare sub traitement
Declare sub parcourir
Declare sub btn_maj
Declare sub ListeInitiale
global liste_table() as string
global tables_ouvertes() as string
'-----------------------------------------------------------------------------------------------------------------
'--------------------------------------
'---- Sub Main et création du menu ----
'--------------------------------------
'-----------------------------------------------------------------------------------------------------------------
Sub main
redim liste_table(0)
redim tables_ouvertes(0)
create menu "Extraction de Linéo" as
"Ajout et mise à jour des champs" calling traitement
alter menu bar add "Extraction de Linéo"
End sub
'-----------------------------------------------------------------------------------------------------------------
'----------------------------------------------
'---- Chargement de l'interface traitement ----
'----------------------------------------------
'-----------------------------------------------------------------------------------------------------------------
Sub traitement
if NumTables()>=1 then
call ListeInitiale
Dialog
Title "Préparation du fichier d'entreprises géolocalisées"
Width 242
Height 150
Position 78,130
Control Statictext
id 1
Width 65
Height 13
Position 13,13
Title "Table géocodée :"
Control Statictext
id 2
Width 81
Height 13
Position 13,67
Title "Table de données :"
Control Listbox
id 3
Width 175
Height 31
Position 13,27
title from variable liste_table
Control Listbox
id 4
Width 175
Height 12
Position 13,80
Title from variable tables_ouvertes
Control Button
id 6
Width 20
Height 13
Position 199,80
Title "..."
calling parcourir
Control Okbutton
id 7
Width 60
Height 22
Position 54,107
Title "Mettre à jour"
calling btn_maj
Control Cancelbutton
id 8
Width 60
Height 22
Position 129,107
Title "Quitter"
else
note "Au moins une table doit être ouverte ..."
end if
end sub
'-----------------------------------------------------------------------------------------------------------------
'-----------------------------------------------------------------------
'---- Initialisation de la liste : affiche les tables déjà ouvertes ----
'-----------------------------------------------------------------------
'-----------------------------------------------------------------------------------------------------------------
sub ListeInitiale
dim w_nb as smallint
dim i as smallint
redim liste_table(0)
w_nb = 0
i=0
w_nb = NumTables()
redim liste_table(w_nb)
for i=1 to w_nb
liste_table(i) = tableinfo(i, TAB_INFO_NAME)
next
end sub
'---- Parcourir ----
Sub parcourir
dim w_file as string
dim w_nom_table as string
dim w_nb as integer
w_file = ""
w_nom_table = ""
w_nb = 0
w_file = fileopendlg ("","","tab","Choix d'une nouvelle table")
If w_file <> "" then
w_nom_table = PathToTableName$(w_file)
if tables_ouvertes(w_nom_table) = FALSE then
open table w_file
w_nb = ubound(tables_ouvertes) + 1
redim tables_ouvertes(w_nb)
tables_ouvertes(w_nb) = tableinfo(w_nb,TAB_INFO_NAME)
alter control 4 title from variable tables_ouvertes value w_nb
end if
end if
End sub
'-------
'---- bouton Mise à Jour ----
Sub btn_maj
dim w_indice_table_geo as smallint
dim w_indice_table_data as smallint
dim w_nom_table_geo as string
dim w_nom_table_data as string
dim i as integer
Dim Nb_Col As Integer
w_indice_table_geo = 0
w_indice_table_data = 0
w_indice_table_geo = readcontrolvalue(3)
w_indice_table_data = readcontrolvalue(4)
if w_indice_table_geo > 0 AND w_indice_table_data > 0 then
w_nom_table_geo = liste_table(w_indice_table_geo)
w_nom_table_data = tables_ouvertes(w_indice_table_data)
Alter Table w_nom_table_geo ( add Telephone_courant_entreprise Char(14),Fax_courant_entreprise Char(14),Libelle_statut_de_l_entreprise Char(18),Siege_entreprise__O_N_ Char(1),Forme_juridique_entreprise Float,Date_creation_entreprise Date,Web_courant_entreprise Char(100),Immatriculation_entreprise Char(2),Capital_entreprise Float,Effectif_entreprise Float,Date_effectif_entreprise Date,APE_entreprise Char(10),Commentaire_activite_entrepris Char(150),Accord_mailing Char(1) modify numero_de_voie_2_entreprise Float order siret_entreprise,raison_sociale_courte_entrepris,sigle_entreprise,enseigne_entreprise,nom_commercial_entreprise,voie_entreprise,numero_de_voie_entreprise,numero_de_voie_2_entreprise,libelle_comp_num_voie_entrepri,libelle_designation_voie_entrep,nom_voie_entreprise,complement_nom_voie_entreprise,code_postal_entreprise,libelle_commune_entreprise,commune_entreprise,Telephone_courant_entreprise,Fax_courant_entreprise,Libelle_statut_de_l_entreprise,Siege_entreprise__O_N_,Forme_juridique_entreprise,Date_creation_entreprise,Web_courant_entreprise,Immatriculation_entreprise,Capital_entreprise,Effectif_entreprise,Date_effectif_entreprise,APE_entreprise,Commentaire_activite_entrepris,Accord_mailing,MI_CQ) Interactive
Add Column w_nom_table_geo (Telephone_courant_entreprise )From w_nom_table_data Set To Téléphone_courant_entreprise Where COL1 = COL1
Add Column w_nom_table_geo (Libelle_statut_de_l_entreprise )From w_nom_table_data Set To Libellé_statut_de_l_entreprise Where COL1 = COL1
Add Column w_nom_table_geo (Siege_entreprise__O_N_ )From w_nom_table_data Set To Siège_entreprise__O_N_ Where COL1 = COL1
Add Column w_nom_table_geo (Forme_juridique_entreprise )From w_nom_table_data Set To Forme_juridique_entreprise Where COL1 = COL1
Add Column w_nom_table_geo (Date_creation_entreprise )From w_nom_table_data Set To Date_création_entreprise Where COL1 = COL1
Add Column w_nom_table_geo (Web_courant_entreprise )From w_nom_table_data Set To Web_courant_entreprise Where COL1 = COL1
Add Column w_nom_table_geo (Immatriculation_entreprise )From w_nom_table_data Set To Immatriculation_entreprise Where COL1 = COL1
Add Column w_nom_table_geo (Capital_entreprise )From w_nom_table_data Set To Capital_entreprise Where COL1 = COL1
Add Column w_nom_table_geo (Effectif_entreprise )From w_nom_table_data Set To Effectif_entreprise Where COL1 = COL1
Add Column w_nom_table_geo (Date_effectif_entreprise )From w_nom_table_data Set To Date_effectif_entreprise Where COL1 = COL1
Add Column w_nom_table_geo (APE_entreprise )From w_nom_table_data Set To APE_entreprise Where COL1 = COL1
Add Column w_nom_table_geo (Commentaire_activite_entrepris )From w_nom_table_data Set To Commentaire_activité_entrepris Where COL1 = COL1
Add Column w_nom_table_geo (Accord_mailing )From w_nom_table_data Set To Accord_mailing Where COL1 = COL1
end if
end subToute la fin du programme n'est pas encore faite (Alter table et Add Column), et la partie concernée est la sub parcourir (ListeInitiale concerne la première zone de liste)
Merci de votre aide!!!
Hors ligne
#2 Thu 22 November 2012 17:04
- Damien BEAUSEIGNEUR
- Participant assidu
- Lieu: meyzieu
- Date d'inscription: 5 Sep 2005
- Messages: 425
Re: [MapBasic] Bouton parcourir "..." ne marche pas!
Bonjour,
après une première lecture une question me vient comment cela ce fait-il que cela ne plante pas.
tables_ouvertes() n'est pas une fonction, mais un tableau de variables donc mettre un nom en paramètre...
de plus tables_ouvertes te renverra soit '' soit un null, mais jamais un false.
si tu veux une fonction ok mais change de nom ça sera plus lisible, cette fonction devra rechercher si le w_nom_table est dans ta liste des tables ouvertes.
cordialement
Hors ligne


