Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use clarion help examples?

Status
Not open for further replies.

newtoclarion

Programmer
Jul 20, 2011
66
0
0
SA
I face problem in trying the code in clarion 6.3 help
I see the code but dont know where to put it
for example these codes
!***code 1*******
PROGRAM !Example program code

MAP
OpenFile PROCEDURE(FILE AnyFile)!Procedure prototype with parameter
ShoTime PROCEDURE !Procedure prototype without parameter
DayString PROCEDURE,STRING !Procedure prototype with a return value
END


FileOne FILE,DRIVER('Clarion') !Declare a file

RECORD !begin record declaration
Name STRING(20)
Number LONG
END ! end record declaration
END !End file declaration


TodayString STRING(9)
CODE
TodayString = DayString() !Procedure called with a return value
OpenFile(FileOne) !Call procedure to open file
ShoTime !Call ShoTime procedure
!More executable statements

OpenFile PROCEDURE(FILE AnyFile)!Open any file

CODE !Begin code section
OPEN(AnyFile) !Open the file
IF ERRORCODE() = 2 !If file not found
CREATE(AnyFile) !create it
END
RETURN !Return to caller

ShoTime PROCEDURE !Show time
Time LONG !Local variable
Window WINDOW,CENTER
STRING(@T3),USE(Time),AT(34,70)
BUTTON('Exit'),AT(138,92),USE(?Exit)
END
CODE !Begin executable code section

Time = CLOCK() !Get time from system
OPEN(Window)
ACCEPT
CASE ACCEPTED()
OF ?Exit
BREAK
END
END
RETURN !Return to caller

DayString PROCEDURE !Day string procedure
ReturnString STRING(9),AUTO !Uninitialized local stack variable
CODE !Begin executable code section
EXECUTE (TODAY() % 7) + 1 !Find day of week from system date
ReturnString = 'Sunday'

ReturnString = 'Monday'
ReturnString = 'Tuesday'
ReturnString = 'Wednesday'
ReturnString = 'Thursday'
ReturnString = 'Friday'
ReturnString = 'Saturday'
END
RETURN(ReturnString) !Return the resulting string
!**********code2*****
Name CSTRING(21) !Declare 21 byte field - 20 bytes data

OtherName CSTRING(21),OVER(Name) !Declare field over name field
Contact CSTRING(21),DIM(4) !Array 21 byte fields - 80 bytes data
Company CSTRING('SoftVelocity Corporation') !21 byte string - 20 bytes data
Phone CSTRING(@P(###)###-####P) !Declare 14 bytes - 13 bytes data
ExampleFile FILE,DRIVER('Btrieve') !Declare a file
Record RECORD
NameField CSTRING(21),NAME('ZstringField') !Declare with external name

END
END
CODE
Name = 'Tammi' !Assign a value
Name[5] = 'y' ! then change fifth letter
Name[6] = 's' ! then add a letter
Name[7] = '<0>' ! and handle null terminator
Name[5:6] = 'ie' ! and change a "slice"
! -- the fifth and sixth letters
Contact[1] = 'First' !Assign value to first element
Contact[1,2] = 'u' !Change first element 2nd character

Contact[1,2:3] = Name[5:6] !Assign slice to slice
!*****end****************
please help
 
Hi!

Clarion programmers normally develop using the Application IDE which generates the required code. There are a lot of hand coders as well.

Help normally contain snippets of code which fit into the bigger context of the program. So, cutting & pasting from the help without knowing how a clarion program is structured will not work.
It is better to start with the "Getting Started" part of the help followed by the tutorials.

What are you actually trying to do and what version of Clarion are you using?

Regards
 
Iam using 6.3
I have nothing special, just trying to learn more from help.
if you can tell me how to use the 2 examples I mentioned it will will be a good start for me.
thanx so much

 
Hi!

A working version of your test program is below. I am not sure what you are going to learn from this.

Code:
 PROGRAM                         !Example program code

 MAP
OpenFile   PROCEDURE(FILE AnyFile),BYTE !Procedure prototype with parameter
ShowTime   PROCEDURE              !Procedure prototype without parameter
DayString  PROCEDURE,STRING       !Procedure prototype with a return value
 END 

FileOne   FILE,DRIVER('Topspeed'),NAME('FileOne.TPS'),PRE(FIL),CREATE  !Declare a file
Record      RECORD                 !begin record declaration
CurrDay       STRING(10)
CurrDate      DATE
CurrTime      TIME
            END                    ! end record declaration
          END                      !End file declaration

  CODE

  IF NOT OpenFile(FileOne) THEN RETURN.              !Call procedure to open file
  
  CLEAR(FIL:Record)
  FIL:CurrDay  = DayString()
  FIL:CurrDate = TODAY()
  FIL:CurrTime = CLOCK()
  
  ADD(FileOne)
  IF ERRORCODE()
     MESSAGE('Error # = ' & ERRORCODE() & '  Error Description = ' & ERROR(), 'E R R O R')
     RETURN
  END
  
  ShowTime()                        !Call ShowTime procedure
  
  RETURN
 
OpenFile PROCEDURE(FILE AnyFile)!Open any file

  CODE                           !Begin code section
  
  OPEN(AnyFile)                  !Open the file
  IF ERRORCODE() = 2             !If file not found
     CREATE(AnyFile)             !create it
     IF NOT ERRORCODE()
        OPEN(AnyFile)
     END
  END   
  IF ERRORCODE()
     MESSAGE('Error # = ' & ERRORCODE() & '  Error Description = ' & ERROR(), 'E R R O R')
     RETURN FALSE
  END   
  RETURN TRUE                         !Return to caller

ShowTime PROCEDURE               !Show time

Window WINDOW('Current Date/Day/Time'),AT(,,97,82),CENTER,FONT('Microsoft Sans Serif', 10,, FONT:regular, CHARSET:DEFAULT),DOUBLE
    STRING(@D3), AT(26,25), USE(FIL:CurrDate), CENTER
    STRING(@T3), AT(32,9), USE(FIL:CurrTime), CENTER
    STRING(@S10), AT(27,41), USE(FIL:CurrDay), CENTER
    BUTTON('Exit'), AT(32,60), USE(?Exit)
 END
 
 CODE                           !Begin executable code section

 OPEN(Window)
 ACCEPT
  CASE ACCEPTED()
  OF ?Exit
   BREAK
  END
 END
 CLOSE(Window)
 RETURN                         !Return to caller

DayString   PROCEDURE           !Day string procedure

ReturnString STRING(9),AUTO     !Uninitialized local stack variable

 CODE                           !Begin executable code section

 EXECUTE (TODAY() % 7) + 1      !Find day of week from system date
   ReturnString = 'Sunday'

   ReturnString = 'Monday'
   ReturnString = 'Tuesday'
   ReturnString = 'Wednesday'
   ReturnString = 'Thursday'
   ReturnString = 'Friday'
   ReturnString = 'Saturday'
 END
 
 RETURN(ReturnString)           !Return the resulting string

Regards
 
That is my point , It is not the code itself but I dont know where to put the code and run it.

thank you for the follow up.


 
I tried to take that code as an example:
I opened a new window procedure and put the data definations in the data section, created a button and put the code in it ... etc.
It took a lot of work to make it run. I am sure there is a direct way or a short cut to do it. but I couldnt find it, I tried to put the code as .clw file and call it but didnt work.

Please experts tell me how to do it right with many thanks.
 
Hi!

It is not possible to teach you Clarion over a newsgroup!

What version of Clarion are you using? Is it a legal copy i.e. not pirated. If it is a legal copy, you should have the help file & tutorials in it. Start with the help file - 1) Getting Started, 2) User Guide and Lessons & 3) Guide to all examples. The example applications will be in the <ClarionMainFolder>\Examples folder. Go through them one by one and whenever you want help with the Language, check out the Language Reference in the help.

On top of that, there is a paid training program from SoftVelocity ( which can be very useful to you.

Once you have done the above and you still want help, detail what you have done in clear steps so that I can understand it. Also, I use the Clarion 7 IDE and may not be able to help you in previous versions.

Regards
 
Hi!

Also, there are quite a few SWF videos in the <ClarionMainFolder\BIN\Flash folder which are called from the help but can also be called directly.

Regards
 
Dear ShankarJ.
Iam so sorry for the whole confussion.
May be my way of asking was not correct, Iam a programmer and I have good knowledge in clarion, even I create templates some times.
My mistake from the begining that I took two dummy codes from the help to explain my idea and that was wrong.

what I need exactly is a way to take any example from the help (complecated ones)and paste it somewhere and make it run. the examples I gave are simple and any programmer can understand them, I know, I just pressed help button, coppied and pasted the first two examples I faced to explain my idea.

Iam using clarion 6.3 (Legal copy)
I hope you got my point
Many thanks again
 
Hi!

Well... the only place you can paste anything from the help is in the EMBEDS. But you will have to adapt the pasted text into the context of your application for it to work.

Regards
 
I expected that .. thank you for your patience ShankarJ
wish you best of luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top