收藏 分享(赏)

labwindowscvi5第六章-数据格式化、文件读取和io端口操作.ppt

上传人:天天快乐 文档编号:1076506 上传时间:2018-06-10 格式:PPT 页数:11 大小:382.50KB
下载 相关 举报
labwindowscvi5第六章-数据格式化、文件读取和io端口操作.ppt_第1页
第1页 / 共11页
labwindowscvi5第六章-数据格式化、文件读取和io端口操作.ppt_第2页
第2页 / 共11页
labwindowscvi5第六章-数据格式化、文件读取和io端口操作.ppt_第3页
第3页 / 共11页
labwindowscvi5第六章-数据格式化、文件读取和io端口操作.ppt_第4页
第4页 / 共11页
labwindowscvi5第六章-数据格式化、文件读取和io端口操作.ppt_第5页
第5页 / 共11页
点击查看更多>>
资源描述

1、LabWindows/CVI教程(5)文件和端口操作主讲:乔立岩Email: (交作业) MSN: (在线交流)Tel: 86413532 ext. 8611 (逸夫楼611),2018/6/10,字符串操作Formatting and I/OString ManipulationStringLengthint StringLength (char String);i = StringLength (str);StringLowerCasevoid StringLowerCase (char String);StringLowerCase (str);StringUpperCaseCompa

2、reStringint CompareStrings (char String_#1, int String_#1_Index, char String_#2, int String_#2_Index, int Case_Sensitive?);i = CompareStrings (str1, ind1, str2, ind2, 0);CopyString ,2018/6/10,Programmers ToolboxString HandlingAppendStringint AppendString (char *Pointer_To_String_To_Append_To, const

3、char String_To_Append, int Num_Characters_To_Append);AppendString (str1, str2, -1);StrDupchar *StrDup (const char String_To_Duplicate);str = StrDup (virtual instrumentation lesson);RemoveSurroundingWhiteSpacevoid RemoveSurroundingWhiteSpace (char String);RemoveSurroundingWhiteSpace (str);SkipWhiteSp

4、aceStrICmpWithoutSurrWhiteSpace ,2018/6/10,数据格式化(Data Formatting)Fmt 将一个或多个源数据(item)格式化到一个目标数据变量中 int Fmt (void *Target, char Format_String, .);Fmt (str, %s%d, 格式符%s字符串%d, %i 整型%f浮点型%10f浮点型数组,2018/6/10,修饰符修饰符:wn, tn, t#, pn, bn 举例int iData100;float fData100; Fmt(iData, ”%100d%st#%f,str1, Fmtwizard,2

5、018/6/10,定时/等待(Timer/Wait)Timerdouble Timer (void)Delayvoid Delay (double Number_of_Seconds);Delay(3.0);SyncWaitvoid SyncWait (double Begin_Time, double Interval);SyncWait(mark, interval);日期/时间(Date/Time)DateStrchar *DateStr (void); 格式:MM-DD-YYYYTimeStrchar *TimeStr (void); 格式:HH:MM:SSGetSystemTimei

6、nt GetSystemTime (int *Hours, int *Minutes, int *Seconds);,2018/6/10,文件应用UtilitiesFile UtilitiesDeleteFileint DeleteFile (char File_Name);i = DeleteFile (*.doc);RenameFileint RenameFile (char Existing_File_Name, char New_File_Name);i = RenameFile (test1.dat, test2.dat);CopyFileint CopyFile (char Sou

7、rce_File_Name, char Target_File_Name);i = CopyFile (“test1.dat”, “test2.dat”);GetFileAttrsint GetFileAttrs (char File_Name, int *Read-Only, int *System, int *Hidden, int *Archive);i = GetFileAttrs (test.dat, ,2018/6/10,Formatting and I/OFile I/OOpenFileint OpenFile (char File_Name, int Read/Write_Mo

8、de, int Action, int File_Type)fp = OpenFile (test.dat, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_BINARY);CloseFileint CloseFile (int File_Handle);ReadFileint ReadFile (int File_Handle, char Buffer, int Count);ReadFile (fp, data, 8);WriteFileint WriteFile (int File_Handle, char Buffer, int Count);WriteFile

9、(fp, data, 8);ArrayToFileFileToArray,2018/6/10,ANSI Cstdio.hfopenFILE *fopen (const char File_Name, const char Mode);fp = fopen (test.dat, wb+);fcloseint fclose (FILE *Stream);i = fclose (fp);freadsize_t fread (void *Buffer, size_t Element_Size, size_t Number_of_Elements, FILE *Stream);num = fread (

10、data, 4096, 1024, fp);fwritesize_t fwrite (const void *Buffer, size_t Element_Size, size_t Number_of_Elements, FILE *Stream);num = fwrite (data, 4096, 1024, fp);ftelllong ftell (FILE *Stream);pos = ftell (fp);fseekint fseek (FILE *Stream, long Offset, int Origin);i = fseek (fp, 256, SEEK_SET);,2018/

11、6/10,路径应用(Directory Utilities)GetDirint GetDir (char Current_Directory);i = GetDir (dir);SetDirDeleteDirint DeleteDir (char Directory_Name);i = DeleteDir (d:testdata);MakeDirint MakeDir (char Directory_Name);i = MakeDir (d:testdata);GetProjectDirint GetProjectDir (char Directory_Name);i = GetProjectDir (dir); ,2018/6/10,IO端口(Port IO)inpchar inp (short Port_Number);i = inp (0x220+4);j = inp (0x220+5);k = j*256+i;inpwk = inpw (0x220+4);inpdoutpchar outp (short Port_Number, char Byte);i = outp (0x2c0+5, ch);outpwoutpd,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 经营企划

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报