Not able to retrieve the facts in clips - expert-system
I wish to get a list of friends by using a function.
(deffunction get-freinds-list (?age)
(bind ?facts (find-all-facts ((?f userdata))
(and (eq ?f:name userdata)
(>= ?f:age ?age))))
return ?facts)
(defrule getfriends
(wantlist yes)
=>
(printout t "under what age you want list for?" crlf)
(bind ?age (read))
(printout t "list is=" (get-freinds-list ?age ) crlf))
(defrule main-control
(initial-fact)
=>
(assert(wantlist yes))
)
(deffacts userfact
(userdata(name "pranay" )(likes tea cricket badminton table farewell)(age 12)(location pakistan)(employer Oracle))
(userdata(name "rohan" )(likes lunch kabaddi tt khoko farewell)(age 10)(location china)(employer TCS))
(userdata(name "srinath" )(likes dinner kabaddi cricket farewell)(age 15)(location china)(employer TCS))
(userdata(name "prateek" )(likes dinner kabaddi cricket farewell drinks)(age 15)(location china)(employer TCS))
(userdata(name "sachin" )(likes drinks kabaddi cricket)(age 15)(location china)(employer TCS))
)
(deftemplate userdata "Knoweledge base"
(slot name)
(multislot likes)
(slot age)
(slot location)
(slot employer)
)
CLIPS>
(deftemplate userdata "Knowledge base"
(slot name)
(multislot likes)
(slot age)
(slot location)
(slot employer))
CLIPS>
(deffunction get-friends-list (?age)
(bind ?list (create$))
(do-for-all-facts ((?f userdata)) (>= ?f:age ?age)
(bind ?list (create$ ?list ?f:name)))
return ?list)
CLIPS>
(defrule getfriends
(wantlist yes)
=>
(printout t "under what age you want list for? ")
(bind ?age (read))
(printout t "list is " (implode$ (get-friends-list ?age)) crlf))
CLIPS>
(deffacts main-control
(wantlist yes))
CLIPS>
(deffacts userfact
(userdata (name "pranay") (likes tea cricket badminton table farewell) (age 12) (location pakistan) (employer Oracle))
(userdata (name "rohan") (likes lunch kabaddi tt khoko farewell) (age 10) (location china) (employer TCS))
(userdata (name "srinath") (likes dinner kabaddi cricket farewell) (age 15)(location china) (employer TCS))
(userdata (name "prateek") (likes dinner kabaddi cricket farewell drinks) (age 15) (location china)(employer TCS))
(userdata (name "sachin") (likes drinks kabaddi cricket) (age 15) (location china) (employer TCS)))
CLIPS> (reset)
CLIPS> (run)
under what age you want list for? 13
list is "srinath" "prateek" "sachin"
CLIPS> (reset)
CLIPS> (run)
under what age you want list for? 9
list is "pranay" "rohan" "srinath" "prateek" "sachin"
CLIPS>
Related
DraftSight Lisp - Blank/Empty Dialog Box Lock
I'm trying to create a Yes/No/Cancel dialog box in DraftSight by using a tutorial's solution (Link to site). However, when I try to add the first message to the dialog box, the program breaks, and the dialog box opens without any code to close the dialog box. Using task manager to stop DraftSight is the only way I can close the dialog box. Is there an issue with the AutoLisp code that I'm using? References: DraftSight/Solidworks Lisp Lisp code: ;; Source: https://www.afralisp.net/dialog-control-language/tutorials/the-autolisp-message-box.php ;; Lisp code from tutorial (defun lspYesNoCancel (message1 message2 message3 main) (setq msgboxPath "C:\\Users\\GarrettB\\Documents\\Visual Studio Code\\DraftSight LISP") (princ (strcat msgboxPath "\n")) (princ) ;; Loading the dialoge box file and returning the ID file (princ "YesNoCancel 01\n") (setq dcl_id (load_dialog (strcat msgboxPath "\\" "msgbox.dcl"))) (princ "YesNoCancel 02\n") ;; Creating the dialoge box (if (not (new_dialog "lspYesNoCancel" dcl_id "(done_dialog)")) (exit)) (princ "YesNoCancel 03\n") (princ dcl_id)(princ "\n") ;; Dialoge Message (if (set_tile "message1" message1)(princ "Message added to message1\n")(exit)) (princ "YesNoCancel 04-1\n") (if (set_tile "message2" message2)(princ "Message added to message2\n")(exit)) (if (set_tile "message3" message3)(princ "Message added to message3\n")(exit)) (if (set_tile "main" main)(princ "Message added to main\n")(exit)) (princ "YesNoCancel 04-4\n") ;; Command Buttons (if (action_tile "no" "(done_dialog) (setq result \"F\")")(princ "No command added\n")(exit)) (if (action_tile "yes" "(done_dialog) (setq result T)")(princ "Yes command added\n")(exit)) (if (action_tile "cancel" "(done_dialog) (setq result nil)")(princ "Cancel command added\n")(exit)) (princ "YesNoCancel 05\n") ;; Interaction (exit) (quit) ;; (start_dialog) ;----; Show dialog box (unload_dialog dcl_id) ; Closes the link to the .dcl file (princ) ) dcl code: lspYesNoCancel : dialog { key = "main"; : column { : text {Key = "message1";} : text {key = "message2";} : text {key = "message3";} } : row { : spacer {width = 1;} : button { label = "Yes"; key = "yes"; width = 12; fixed_width = true; mnemonic = "Y"; is_default = true; } : button { label = "No"; key = "no"; width = 12; fixed_width = true; mnemonic = "N"; } : button { label = "Cancel"; key = "cancel"; width = 12; fixed_width = true; mnemonic = "C"; is_cancel = true; } : spacer {width = 1;} } }
In the line : text {Key = "message1";}, Key needs to have a lowercase "k." Therefore this : text {key = "message1";} is the right answer.
PowerQuery - Add file name as a column
I'm new to PQ We are working in a retail environment. For each promotional event, multiple employees work on an excel template and forecast for their SKUs. I'm trying to merge forecast excel files from multiple employees to get a simple Sku resume. So for each file, I built a loading template making it ready to merge in the master query. So far that's fine. The only thing I'm trying to achieve is to add the file name as a custom column for reference. Heres the simple code I have for each forecast file. Source = Excel.Workbook(File.Contents("C:\Users\aproulx\J.E. Mondou\Promotions - Rapport Logistique Template Alex\12 DÉCEMBRE\Estimés_circulaire_décembre_2020_Gen.xlsx"), null, true), EXPORT_Sheet = Source{[Item="Estimés",Kind="Sheet"]}[Data], #"Premières lignes supprimées" = Table.Skip(EXPORT_Sheet,4), #"En-têtes promus" = Table.PromoteHeaders(#"Premières lignes supprimées"), #"Colonnes renommées" = Table.RenameColumns(#"En-têtes promus",{{"Lift", "Lift_PC_MAG"}, {"Estimés (PC)", "Estimés_PC_MAG"}, {"Estimés ($)", "Estimés_$_MAG"}, {"Lift_1", "Lift_PC_WEB"}, {"Estimés (PC)_2", "Estimés_PC_WEB"}, {"Estimés ($)_3", "Estimés_$_WEB"}, {"Lift PC Chaine", "Lift_PC_CHAINE"}, {"Quantités Promo Est. (PC)", "Estimés_PC_CHAINE"}, {"Ventes promos Est. (S)", "Estimés_$_CHAINE"}, {"Marges Promos Est. ($)", "Estimés_MARGES_$_CHAINE"}}), #"Colonnes supprimées" = Table.RemoveColumns(#"Colonnes renommées",{"Commentaires/#(lf)Comments", "Évènement/#(lf)Event", "Date début/#(lf)Start date", "Date fin/#(lf)End Date", "Nombre de jour promo", "Description de la promotion/#(lf)Promotion description", "Bonus Buy", "Type de promotion", "Texte SAP", "Description WAK", "# WAK", "Carreau", "Groupe #(lf)d'acheteur", "Groupe d'autorisation", "Ancien #(lf)Mondou Code", "Statut toutes chaînes", "Valeur#(lf)visibilité", "Fournisseur/#(lf)Supplier", "#", "Devise/#(lf)Currency", "Emplacement/#(lf)Position", "Frais de visibilité payé/#(lf)Paid visibility fee", "Option du menu promotionnel/#(lf)Promotionnal menu option", "Frais de menu promotionnel/#(lf)Promotionnal menu fee", "# Accord MP", "Allocation sur ventes/#(lf)Sales allowance ($)", "# Accord", "Allocation sur ventes/#(lf)Sales allowance (Pt câlin/Cuddle points)", "# Accord CÂLIN", "Allocation sur achats/#(lf)Off invoice", "Confirmation", "Rabais #(lf)Promotionnel", "Coûtant #(lf)Promotionnel", "Prix de vente #(lf)Promotionnel", "Marge #(lf)Promotionnelle (%)", "Coûtant de base #(lf)Régulier", "Coûtant net #(lf)Régulier", "Prix de vente#(lf)Régulier", "Marge #(lf)Régulière (%)", "Ventes régulières/Semaine#(lf)(moy. 12 dernières semaines)", "Baseline", "% Web", "Ventes régulières/Semaine#(lf)(moy. 12 dernières semaines)_4", "Baseline_5", "Quantités Reg. (PC)", "Ventes Reg. ($)", "Marges Reg. ($)", "Quantités Lift (PC)", "Ventes Lift ($)", "Marges Lift ($)", "Quantités Lift (%)", "Ventes Lift (%)", "Marges Lift (%)", "Estimés à 0", "Estimés dans rapport logistique", "Identiques?", "Groupe de Marchandise", "Marque", "% SKU", "% G.D.M / MARQUE", "% G.D.M", "3 PREM NIVEAUX", "AVG", "écart-type", "Magasin", "Entrepôt", "Column81"}), #"Lignes filtrées" = Table.SelectRows(#"Colonnes supprimées", each ([Mondou Code] <> null)) in #"Lignes filtrées"``` Thanks so much for the help
Would something like this work? See FileName in the first line defined and assigned as a variable Then it's concat with the file path At the end, it's added as a custom column It's untested. Let me know if it works. let FileName = "Estimés_circulaire_décembre_2020_Gen.xlsx", Source = Excel.Workbook(File.Contents("C:\Users\aproulx\J.E. Mondou\Promotions - Rapport Logistique Template Alex\12 DÉCEMBRE\" & FileName), null, true), EXPORT_Sheet = Source{[Item="Estimés",Kind="Sheet"]}[Data], #"Premières lignes supprimées" = Table.Skip(EXPORT_Sheet,4), #"En-têtes promus" = Table.PromoteHeaders(#"Premières lignes supprimées"), #"Colonnes renommées" = Table.RenameColumns(#"En-têtes promus",{{"Lift", "Lift_PC_MAG"}, {"Estimés (PC)", "Estimés_PC_MAG"}, {"Estimés ($)", "Estimés_$_MAG"}, {"Lift_1", "Lift_PC_WEB"}, {"Estimés (PC)_2", "Estimés_PC_WEB"}, {"Estimés ($)_3", "Estimés_$_WEB"}, {"Lift PC Chaine", "Lift_PC_CHAINE"}, {"Quantités Promo Est. (PC)", "Estimés_PC_CHAINE"}, {"Ventes promos Est. (S)", "Estimés_$_CHAINE"}, {"Marges Promos Est. ($)", "Estimés_MARGES_$_CHAINE"}}), #"Colonnes supprimées" = Table.RemoveColumns(#"Colonnes renommées",{"Commentaires/#(lf)Comments", "Évènement/#(lf)Event", "Date début/#(lf)Start date", "Date fin/#(lf)End Date", "Nombre de jour promo", "Description de la promotion/#(lf)Promotion description", "Bonus Buy", "Type de promotion", "Texte SAP", "Description WAK", "# WAK", "Carreau", "Groupe #(lf)d'acheteur", "Groupe d'autorisation", "Ancien #(lf)Mondou Code", "Statut toutes chaînes", "Valeur#(lf)visibilité", "Fournisseur/#(lf)Supplier", "#", "Devise/#(lf)Currency", "Emplacement/#(lf)Position", "Frais de visibilité payé/#(lf)Paid visibility fee", "Option du menu promotionnel/#(lf)Promotionnal menu option", "Frais de menu promotionnel/#(lf)Promotionnal menu fee", "# Accord MP", "Allocation sur ventes/#(lf)Sales allowance ($)", "# Accord", "Allocation sur ventes/#(lf)Sales allowance (Pt câlin/Cuddle points)", "# Accord CÂLIN", "Allocation sur achats/#(lf)Off invoice", "Confirmation", "Rabais #(lf)Promotionnel", "Coûtant #(lf)Promotionnel", "Prix de vente #(lf)Promotionnel", "Marge #(lf)Promotionnelle (%)", "Coûtant de base #(lf)Régulier", "Coûtant net #(lf)Régulier", "Prix de vente#(lf)Régulier", "Marge #(lf)Régulière (%)", "Ventes régulières/Semaine#(lf)(moy. 12 dernières semaines)", "Baseline", "% Web", "Ventes régulières/Semaine#(lf)(moy. 12 dernières semaines)_4", "Baseline_5", "Quantités Reg. (PC)", "Ventes Reg. ($)", "Marges Reg. ($)", "Quantités Lift (PC)", "Ventes Lift ($)", "Marges Lift ($)", "Quantités Lift (%)", "Ventes Lift (%)", "Marges Lift (%)", "Estimés à 0", "Estimés dans rapport logistique", "Identiques?", "Groupe de Marchandise", "Marque", "% SKU", "% G.D.M / MARQUE", "% G.D.M", "3 PREM NIVEAUX", "AVG", "écart-type", "Magasin", "Entrepôt", "Column81"}), #"Lignes filtrées" = Table.SelectRows(#"Colonnes supprimées", each ([Mondou Code] <> null)), Output = Table.AddColumn(#"Lignes filtrées", "File name", each FileName) in Output
how to display many questions in a GUI jess application
I want to make a diagnostic GUI application; i m new in jess. i wrote the Jess in action's book but when i run the code i have just the first question and answer it's like it don't register the answer. i found the error in my code but i didn't see.here is my final code i moved some questions to not make it more code here. i have no code error just that it's doesn't display all the questions like i specified in the rules.What could be my error? (import javax.swing.*) (import java.awt.*) (import java.awt.event.*) ;; Don't clear defglobals on (reset) (set-reset-globals FALSE) (defglobal ?*crlf* = " ") ;; Question and answer templates (deftemplate questions (slot ident) (slot type) (slot texte) (multislot valid)) (deftemplate reponses (slot texte) (slot ident)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Module app-rules (defmodule interview) (defrule MAIN::questions_basique_1 (declare (auto-focus TRUE)) => (assert (ask age))) (defrule MAIN::questions_basique_2 (declare (auto-focus TRUE)) => (assert (ask poids))) (defrule MAIN::questions_basique_3 (declare (auto-focus TRUE)) => (assert (ask symptome_majeur_1))) (defrule MAIN::questions_basique_4 (declare (auto-focus TRUE)) => (assert (ask symptome_majeur_1))) ;; Engine rules ;;questions pour le corps etrangé (defrule MAIN::request-dyspné_oui ;; si le patient a une dyspnée (reponses (ident symptome_majeur_1) (texte ?i&:(eq (str-compare ?i yes)0))) => ;;lui posée la question si elle est brute (assert (ask dypnée_brute))) (defrule MAIN::request-dyspné_brute_oui (declare (auto-focus TRUE)) ;; si le patient a une dyspnée brute (reponses (ident dypnée_brute) (texte ?i&:(eq (str-compare ?i yes)0))) => ;;poser la question sur syndrome de penetration (assert (ask syndrome_penetration))) (defrule MAIN::request-syndrome_penetration_oui (declare (auto-focus TRUE)) ;; si le patient a eu syndrome de pénétration (reponses (ident syndrome_penetration) (texte ?i&:(eq (str-compare ?i yes)0))) => ;;poser la quetion sur des rales sibilants unilatérauxé (assert (ask rales_sibilant_uni))) (defrule MAIN::request-rales_sibilant_uni_oui (declare (auto-focus TRUE)) ;; s'il a des rales sibilants unilatéreaux (reponses (ident rales_sibilant_uni) (texte ?i&:(eq (str-compare ?i yes)0))) => ;;faire une radio du thorax pour définir s'il ya difference de clarté (assert (ask Rx_diff_clarte))) (defrule MAIN::request-Rx_diff_clarte_oui (declare (auto-focus TRUE)) ;; s'il a des differences de clarté (reponses (ident Rx_diff_clarte) (texte ?i&:(eq (str-compare ?i yes)0))) => ;;faire une bronchoscopie (assert (ask Bronchioscopie))) ;; fin de l'interview ;;début du diagnostique (defrule MAIN::Corps-etrange (declare (auto-focus TRUE)) (MAIN::reponses(ident dypnée_brute)(texte yes)) (MAIN::reponses(ident syndrome_penetration)(texte yes)) (MAIN::reponses(ident rales_sibilant_uni)(texte yes)) (MAIN::reponses(ident Rx_diff_clarte)(texte yes)) (MAIN::reponses(ident Bronchioscopie)(texte yes)) => (assert recommend-action "Corps etrangé")(halt)) ;; Results output (deffunction recommend-action (?action) "Give final instructions to the user" (call JOptionPane showMessageDialog ?*frame* (str-cat "I recommend that you " ?action) "Recommendation" (get-member JOptionPane INFORMATION_MESSAGE))) (defadvice before halt (?*qfield* setText "Close window to exit")) ;; Module ask (defmodule ask) ;;poser une question et retourner une reponse (deffunction ask-patient (?question ?type ?valid) "Set up the GUI to ask a question" (?*qfield* setText ?question) (?*apanel* removeAll) (if (eq ?type multi) then (?*apanel* add ?*acombo*) (?*apanel* add ?*acombo-ok*) (?*acombo* removeAllItems) (foreach ?item ?valid (?*acombo* addItem ?item)) else (?*apanel* add ?*afield*) (?*apanel* add ?*afield-ok*) (?*afield* setText "")) (?*frame* validate) (?*frame* repaint)) ;;vérifier si la reponse est bien oui ou non (deffunction is-of-type (?answer ?type ?valid) "Check that the answer has the right form" (if (eq ?type multi) then (foreach ?item ?valid (if (eq (sym-cat ?answer) (sym-cat ?item)) then (return TRUE))) (return FALSE)) (if (eq ?type number) then (return (is-a-number ?answer))) ;; plain text (return (> (str-length ?answer) 0))) (deffunction is-a-number (?value) (try (integer ?value) (return TRUE) catch (return FALSE))) (defrule ask::ask-question-by-id "Given the identifier of a question, ask it" (declare (auto-focus TRUE)) (MAIN::questions (ident ?id) (texte ?text) (type ?type)(valid $?valid)) (not (MAIN::reponses (ident ?id))) (MAIN::ask ?id) => (ask-patient ?text ?type ?valid) ((engine) waitForActivations)) (defrule ask::collect-user-input "Check and optionally return an answer from the GUI" (declare (auto-focus TRUE)) (MAIN::questions (ident ?id) (texte ?text) (type ?type)(valid ?valid)) (not (MAIN::reponses (ident ?id))) ?user <- (user-input ?input) ?ask <- (MAIN::ask ?id) => (if (is-of-type ?input ?type ?valid) then (assert (MAIN::reponses (ident ?id) (texte ?input))) (retract ?ask ?user) (return) else (retract ?ask ?user) (assert (MAIN::ask ?id)))) ;; Main window (defglobal ?*frame* = (new JFrame "Assistant Diagnostique en pneumonie pédiatrique")) (?*frame* setDefaultCloseOperation (get-member JFrame EXIT_ON_CLOSE)) (?*frame* setSize 700 700) (?*frame* setVisible TRUE) ;; Question field (defglobal ?*qfield* = (new JTextArea 5 40)) (bind ?scroll (new JScrollPane ?*qfield*)) ((?*frame* getContentPane) add ?scroll) (?*qfield* setText "Please wait...") ;; Answer area (defglobal ?*apanel* = (new JPanel)) (defglobal ?*afield* = (new JTextField 40)) (defglobal ?*afield-ok* = (new JButton OK)) (defglobal ?*acombo* = (new JComboBox (create$ "yes" "no"))) (defglobal ?*acombo-ok* = (new JButton OK)) (?*apanel* add ?*afield*) (?*apanel* add ?*afield-ok*) ((?*frame* getContentPane) add ?*apanel* (get-member BorderLayout SOUTH)) (?*frame* validate) (?*frame* repaint) (deffunction read-input (?EVENT) "An event handler for the user input field" (assert (ask::user-input (sym-cat (?*afield* getText))))) (bind ?handler (new jess.awt.ActionListener read-input (engine))) (?*afield* addActionListener ?handler) (?*afield-ok* addActionListener ?handler) (deffunction combo-input (?EVENT) "An event handler for the combo box" (assert (ask::user-input (sym-cat (?*acombo* getSelectedItem))))) (bind ?handler (new jess.awt.ActionListener combo-input (engine))) (?*acombo-ok* addActionListener ?handler) (deffacts MAIN::question-data "questions posée par le systeme" (questions (ident poids) (type number)(texte "quel poids a-t-il?")(valid)) (questions (ident age) (type number)(texte "quelle age a l'enfant?")(valid)) (questions (ident symptome_majeur_1) (type multi)(texte "presente t-il des dyspnées sifflantes?")(valid yes no)) (questions (ident symptome_majeur_2) (type multi)(texte "presente t-il une toux chronique?")(valid yes no)) (questions (ident dypnée_brute) (type multi)(texte "la dyspnée est-elle brusque?")(valid yes no)) (questions (ident rale_sibilant) (type multi)(texte "a-t-il des rales sibilants?")(valid yes no)) (questions (ident syndrome_penetration) (type multi)(texte "y a t-il eu syndrome de pénétration?")(valid yes no)) (questions (ident rales_sibilant_uni) (type multi)(texte "a t-il/elle des rales sibilants unilatéraux?")(valid yes no)) (questions (ident Rx_diff_clarte) (type multi)(texte "la radio du thorax presente t-elle une difference de clarté des deux champs pulmonaires?")(valid yes no)) (questions (ident Bronchioscopie) (type multi)(texte "la Bronchioscopie montre t-elle un corps étrangé?")(valid yes no)) (ask poids)) (reset) (run-until-halt)
Throw out all (defmodule ...) Remove all MAIN:: and ask::. Delete all (declare (auto-focus TRUE)). Don't use (return) in any right hand side code. In short, don't use modules and (auto-)focus until you are sure you understand what it is doing. I don't think it is necessary with this rather small clp file. The main issue could have been this: Make sure to use (questions ... (valid $?valid)) alway with the $ in front of $?valid or similar - it's a multislot. And I think you need (defrule questions_basique_4 => (assert (ask symptome_majeur_2))) ;; not _1
itgensdf054 on synchronize in Invantive Control
When synchronizing a model in Excel with one block, I receive an itgensdf054 error which indicates that it could not clear the target range where the data of the query below is synchronized into. The full error message is: Could not clear contents of the range ''Aangifte Bebat'!$A$6:$Q$129' of block 'ECO'. Deze wijziging kan niet worden doorgevoerd voor de geselecteerde cellen omdat ze van invloed zijn op een draaitabel. Gebruik de lijst met velden om het rapport te wijzigen. Verplaats de draaitabel en probeer het opnieuw als u cellen wilt invoegen of verwijderen Call stack: Type: System.Runtime.InteropServices.COMException bij System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) bij Microsoft.Office.Interop.Excel.Range.ClearContents() bij Invantive.Producer.Control.SyncToDatabaseForm.SyncDownload(DoWorkEventArgs e) in File176:regel 1508 bij Invantive.Producer.Control.SyncToDatabaseForm.SyncDownload(DoWorkEventArgs e) bij Invantive.Producer.Control.SyncToDatabaseForm.syncBackGroundWorker_DoWork(Object sender, DoWorkEventArgs e) bij System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e) The block 'ECO' synchronizes data from the following query on Exact Online: select /*+ join_set(sik, invoiceid, 100) join_set(sil, invoiceid, 100) join_set(itm, id, 100) join_set(itr, id, 100) */sil.itemcode , sil.description , bom.batchquantity , sil.quantity , sil.netprice , sil.amountdc , sil.vatamountdc , sil.vatcode , sil.vatcodedescription , sil.vatpercentage , sik.invoicenumber , sil.linenumber , itr.itemgroupcode , itm.class_04 --aanpassen naar inrichting klant = assortiment bebat_nomenclatuur , itm.class_10 -- is assortiment 10 instellingen stuklijst explosie , case when sik.invoicenumber is not null then '=if($C{D,.,.,.-5,.}=$C{D,.,.,.-5,.-1}, if($C{D,.,.,^+2,.}= "", $C{D,.,.,^,.-1}, $C{D,.,.,^,.}), $C{D,.,.,^,.})' end ass_itemcode , case when sik.invoicenumber is not null /*=""&ALS(K6=K5;ALS(C6<>"";N6;N5);N6)*/ then '="" & if($C{D,.,.,.-6,.}=$C{D,.,.,.-6,.-1}, if($C{D,.,.,^+2,.} <> "", $C{D,.,.,.-3,.}, $C{D,.,.,.-3,.-1}), $C{D,.,.,.-3,.})' end nomenclatuur from ExactOnlineREST..SalesInvoiceLines sil join ExactOnlineREST..SalesInvoices sik on sil.invoiceid = sik.invoiceid join ExactOnlineREST..Items itm on sil.item = itm.id join ExactOnlineREST..ItemsRead itr on sil.item = itr.id left outer join ExactOnlineXML..BillOfMaterials bom on sil.itemcode = bom.item_code_attr order by sik.invoicenumber , sil.linenumber The query or the model has not changed when it worked before. There is a pivot table in the Excel sheet which summarizes the list of sales details. What is causing this error?
From your comments I understand that the pivot table is in 'Aangifte Bebat' worksheet, but the downloaded is in 'Details' worksheet. I think you have made a slight alteration. Probably you have inserted or moved a new worksheet BEFORE the Details worksheet. Since Invantive Control downloads based upon the number of the worksheet, the data has now been moved. Make sure that the original order of worksheets is restored.
Loading/Modifying/Saving Changes to Text File
Allow me to start by sharing what I have so far: main :: IO () main = do contents <- readFile "filmList.txt" let database = (read contents :: [Film]) putStr "Please enter your username: " userName <- getLine menu database where menu newDb = do putStrLn "\nPlease select an option:" putStrLn "1: Display all films currently in the database" putStrLn "2: Add a new film to the database (and display all films)" putStrLn "3: " putStrLn "4: Save Database" putStrLn "5: Exit" putStr "\nSelected option: " option <- getLine case option of "1" -> putStrLn(displayFilms newDb) "2" -> do putStr "Name of film: " title <- getLine putStr "Name of director: " director <- getLine putStr "Year of release: " year <- getLine putStrLn(displayFilms (addNewFilm title director (read year) newDb)) menu newDb ` I have managed to load a txt file with the database of Film types but I cannot figure out how to go about actually making changes to the data. When I try to run option 2, I get a list of all the films with the newly added one as well but if I then run option 1 to list all films, it doesn't include the newly added film. Should I be saving back to the txt file each time a new Film instance is added? Any help is greatly appreciated, thank you!
Keep in mind that everything in Haskell is immutable. When you write addNewFilm (addNewFilm title director (read year) newDb, that doesn't change the database represented by newDb to include the new information; it merely returns a new database that has all the old information plus the new row. It's your responsibility to choose where and when to use the old database (named, ironically, newDb) or the new one returned by the function. For example, you might write this case instead: case option of "1" -> putStrLn (displayFilms newDb) >> menu newDb "2" -> do ... let evenMoreReallyNewDb = addNewFilm title director (read year) newDb putStrLn (displayFilms evenMoreReallyNewDb) menu evenMoreReallyNewDb You might notice that both cases end with a very similar pattern (a putStrLn . displayFilms and then a menu). Unifying them would be a good idea; see if you can see how to do that yourself. If you want to write the modified database back to the file, you will of course need to do that explicitly using writeFile or a similar function.