how can i save contents of messages window to a file with name of Username from login form

Discussions related to Visual Prolog
danepa
VIP Member
Posts: 57
Joined: 29 Sep 2011 5:54

how can i save contents of messages window to a file with name of Username from login form

Unread post by danepa » 17 Oct 2011 3:30

when i save my program, how can save my data with the name from login form?

So, i will login, and i input some data, and if i save it, it will automatically saved with the username that already inputed from login form.

Need help, please... Thanks...

if i write my code with :
login form

Code: Select all

hasilDiagnosa::login(Nama),
data form

Code: Select all

predicates     login : (string Nama) procedure(o)(i).   facts - memor_msg_txt     memor_msg_txt:(string).   login(Nama) :-         file::save(string::concat(Nama,".txt"),memor_msg_txt).
error c603: The flow pattern '(o,i)' does not exist for 'string::concat/2->'
Daniel

User avatar
Tonton Luc
VIP Member
Posts: 501
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc » 17 Oct 2011 10:42

Hi,
:idea: Try this :

Code: Select all

predicates     login : (string Nama) procedure(i).

danepa
VIP Member
Posts: 57
Joined: 29 Sep 2011 5:54

Re:

Unread post by danepa » 17 Oct 2011 12:43

Tonton Luc wrote:Hi,
:idea: Try this :

Code: Select all

predicates     login : (string Nama) procedure(i).
error c603: The flow pattern '(o)' does not exist for 'hasilDiagnosa::login/1'
Daniel

User avatar
Tonton Luc
VIP Member
Posts: 501
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc » 17 Oct 2011 15:58

and in which project file did you declare it (which name) ?

danepa
VIP Member
Posts: 57
Joined: 29 Sep 2011 5:54

Re:

Unread post by danepa » 18 Oct 2011 1:57

Tonton Luc wrote:and in which project file did you declare it (which name) ?
hasilDiagnosa.pro
Daniel

User avatar
Tonton Luc
VIP Member
Posts: 501
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc » 18 Oct 2011 6:51

Can I see your code before :

Code: Select all

hasilDiagnosa::login(Nama),

danepa
VIP Member
Posts: 57
Joined: 29 Sep 2011 5:54

Re:

Unread post by danepa » 18 Oct 2011 7:26

Tonton Luc wrote:Can I see your code before :

Code: Select all

hasilDiagnosa::login(Nama),

Code: Select all

predicates     onOkClick : button::clickResponder. clauses     onOkClick(_Source) = button::defaultAction :-         RadioState1 = admin_ctl:getRadioState(),         RadioState2 = pasien_ctl:getRadioState(),         if RadioState1 = radioButton::unChecked() and RadioState2 = radioButton::unChecked() then             _ = login::display(getParent())         elseif RadioState1 = radioButton::checked() then             _ = adminOption::display(getParent())         else             Nama = nama_ctl:gettext(),             Password = pass_ctl:gettext(),             hasilDiagnosa::login(Nama),     etc
Daniel

User avatar
Tonton Luc
VIP Member
Posts: 501
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc » 18 Oct 2011 10:52

Your code seem correct.
Sorry, I don't understand what's happened.
Make a re-built all maybe...

danepa
VIP Member
Posts: 57
Joined: 29 Sep 2011 5:54

Re:

Unread post by danepa » 18 Oct 2011 16:05

Tonton Luc wrote:Your code seem correct.
Sorry, I don't understand what's happened.
Make a re-built all maybe...
So, how about this error?

error c603: The flow pattern '(o,i)' does not exist for 'string::concat/2->'
Daniel

Paul Cerkez
VIP Member
Posts: 202
Joined: 6 Mar 2000 0:01

Unread post by Paul Cerkez » 18 Oct 2011 16:23

the (o) error comes from the fact that your declaration for login() allows for the string NAMA to be an output.

When VIP compiles, it tests all possible declared flows patterns. Because your declaration allows the pattern for NAMA to to an output from login(), and concat's only pattern is (i), you have a mismatch.

one way around this is to add a 'conditional'

example:

Code: Select all

predicates     login : (string Nama) procedure(o)(i).   facts - memor_msg_txt     memor_msg_txt:(string).   login(Nama) :-       bound(Nama),  % going from memory, don't have VIP help on this computer     % if Nama is empty, then rthis will fail and drop to the next clasue.      % alternatively, you can use not(free(Nama) to do the same thing.     Nama > "", % prevents a blank filename from being used and causing a windows' file system error.     file::save(string::concat(Nama,".txt"),memor_msg_txt).   login(Nama) :-       Nama = "FAILED", % or whathever you want returned if there is an error       % and any other code you want to alert you that the procedure failed due to no Nama.  
p.
Last edited by Paul Cerkez on 18 Oct 2011 16:25, edited 1 time in total.
AI Rules!
P.

Steve Lympany
VIP Member
Posts: 119
Joined: 31 Mar 2001 23:01

Unread post by Steve Lympany » 18 Oct 2011 16:23

Hi,
The unbound variable will produce the (o). It needs to be bound. Only your second variable is bound.
regards
Steve

Steve Lympany
VIP Member
Posts: 119
Joined: 31 Mar 2001 23:01

Unread post by Steve Lympany » 18 Oct 2011 16:24

:D
crossed responses
s

Paul Cerkez
VIP Member
Posts: 202
Joined: 6 Mar 2000 0:01

Unread post by Paul Cerkez » 18 Oct 2011 16:27

Steve, "great minds thinking alike" as one of my old professors used to say. ;-)
AI Rules!
P.

danepa
VIP Member
Posts: 57
Joined: 29 Sep 2011 5:54

Re:

Unread post by danepa » 19 Oct 2011 2:00

Paul Cerkez wrote:the (o) error comes from the fact that your declaration for login() allows for the string NAMA to be an output.

When VIP compiles, it tests all possible declared flows patterns. Because your declaration allows the pattern for NAMA to to an output from login(), and concat's only pattern is (i), you have a mismatch.

one way around this is to add a 'conditional'

example:

Code: Select all

predicates     login : (string Nama) procedure(o)(i).   facts - memor_msg_txt     memor_msg_txt:(string).   login(Nama) :-       bound(Nama),  % going from memory, don't have VIP help on this computer     % if Nama is empty, then rthis will fail and drop to the next clasue.      % alternatively, you can use not(free(Nama) to do the same thing.     Nama > "", % prevents a blank filename from being used and causing a windows' file system error.     file::save(string::concat(Nama,".txt"),memor_msg_txt).   login(Nama) :-       Nama = "FAILED", % or whathever you want returned if there is an error       % and any other code you want to alert you that the procedure failed due to no Nama.  
p.
error c631: The predicate 'hasilDiagnosa::login/1 (i)', which is declared as 'procedure', is actually 'nondeterm'
Daniel

Paul Cerkez
VIP Member
Posts: 202
Joined: 6 Mar 2000 0:01

Unread post by Paul Cerkez » 19 Oct 2011 11:56

modify the code I posted like this:

Code: Select all

login(Nama) :-      % now that you modified the declaration, you don't need the bound() anymore.    Nama > "", % prevents a blank filename from being used and causing a windows' file system error.     !,  % add the cut right here.     file::save(string::concat(Nama,".txt"),memor_msg_txt).   login(_) :-        !,  % add the cut right here.    stdio::write(" login file save FAILED"), % or whathever you want returned if there is an error
this should take it back to procedure.
AI Rules!
P.

Post Reply