Page 1 of 2

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

Posted: 17 Oct 2011 3:30
by danepa
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->'

Posted: 17 Oct 2011 10:42
by Tonton Luc
Hi,
:idea: Try this :

Code: Select all

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

Re:

Posted: 17 Oct 2011 12:43
by danepa
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'

Posted: 17 Oct 2011 15:58
by Tonton Luc
and in which project file did you declare it (which name) ?

Re:

Posted: 18 Oct 2011 1:57
by danepa
Tonton Luc wrote:and in which project file did you declare it (which name) ?
hasilDiagnosa.pro

Posted: 18 Oct 2011 6:51
by Tonton Luc
Can I see your code before :

Code: Select all

hasilDiagnosa::login(Nama),

Re:

Posted: 18 Oct 2011 7:26
by danepa
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

Posted: 18 Oct 2011 10:52
by Tonton Luc
Your code seem correct.
Sorry, I don't understand what's happened.
Make a re-built all maybe...

Re:

Posted: 18 Oct 2011 16:05
by danepa
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->'

Posted: 18 Oct 2011 16:23
by Paul Cerkez
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.

Posted: 18 Oct 2011 16:23
by Steve Lympany
Hi,
The unbound variable will produce the (o). It needs to be bound. Only your second variable is bound.
regards
Steve

Posted: 18 Oct 2011 16:24
by Steve Lympany
:D
crossed responses
s

Posted: 18 Oct 2011 16:27
by Paul Cerkez
Steve, "great minds thinking alike" as one of my old professors used to say. ;-)

Re:

Posted: 19 Oct 2011 2:00
by danepa
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'

Posted: 19 Oct 2011 11:56
by Paul Cerkez
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.